You are here

public function BlockView::getBlock in Twig Extender 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/TwigPlugin/BlockView.php \Drupal\twig_extender\Plugin\TwigPlugin\BlockView::getBlock()
  2. 8.2 src/Plugin/TwigPlugin/BlockView.php \Drupal\twig_extender\Plugin\TwigPlugin\BlockView::getBlock()
  3. 8.3 src/Plugin/TwigPlugin/BlockView.php \Drupal\twig_extender\Plugin\TwigPlugin\BlockView::getBlock()
  4. 4.x src/Plugin/TwigPlugin/BlockView.php \Drupal\twig_extender\Plugin\TwigPlugin\BlockView::getBlock()

Implementation for render block.

File

src/Plugin/TwigPlugin/BlockView.php, line 24

Class

BlockView
The plugin for check authenticated user.

Namespace

Drupal\twig_extender\Plugin\TwigPlugin

Code

public function getBlock($blockId) {
  $block = Block::load($blockId);
  if (!$block) {
    return;
  }
  $blockContent = \Drupal::entityManager()
    ->getViewBuilder('block')
    ->view($block);
  return \Drupal::service('renderer')
    ->render($blockContent);
}