You are here

public function BlockCreate::getBlock in Twig Extender 8.3

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

Implementation for render block.

File

src/Plugin/TwigPlugin/BlockCreate.php, line 23

Class

BlockCreate
The plugin for check authenticated user.

Namespace

Drupal\twig_extender\Plugin\TwigPlugin

Code

public function getBlock($pluginId, $conf = []) {
  $block_plugin_manager = \Drupal::service('plugin.manager.block');

  /** @var \Drupal\language\Plugin\Block\LanguageBlock $language_block */
  $block = $block_plugin_manager
    ->createInstance($pluginId, $conf);
  if (!$block) {
    return;
  }
  $build = $block
    ->build();
  return \Drupal::service('renderer')
    ->render($build);
}