Define variable from a custom block's content

Public

</> CopyGet raw version
php
  1. $block_id = 1;
  2. $block = \Drupal::entityManager()->getStorage('block_content')->load($block_id);
  3. $block_view = \Drupal::entityManager()->getViewBuilder('block_content')->view($block);
  4. $variables['variable_name'] = $block_view;