You are here

public function BlocksRendererHelper::getRenderFromBlockPlugin in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 src/BlocksRendererHelper.php \Drupal\gutenberg\BlocksRendererHelper::getRenderFromBlockPlugin()

Return render array for given block plugin.

Parameters

\Drupal\Core\Block\BlockPluginInterface $plugin_block: Block Plugin instance.

Return value

array|\Drupal\Component\Render\MarkupInterface Array containing render array, or empty.

File

src/BlocksRendererHelper.php, line 87

Class

BlocksRendererHelper
Class BlocksRendererHelper.

Namespace

Drupal\gutenberg

Code

public function getRenderFromBlockPlugin(BlockPluginInterface $plugin_block) {
  $render = [
    '#theme' => 'block',
    '#attributes' => [],
    '#contextual_links' => [],
    '#configuration' => $plugin_block
      ->getConfiguration(),
    '#plugin_id' => $plugin_block
      ->getPluginId(),
    '#base_plugin_id' => $plugin_block
      ->getBaseId(),
    '#derivative_plugin_id' => $plugin_block
      ->getDerivativeId(),
  ];

  // Build the block.
  $content = $plugin_block
    ->build();
  $this
    ->addPropertiesToRender($render, $content);
  $this
    ->addCacheTagsToRender($render, $content);
  $render['content'] = $content;
  return $this->renderer
    ->renderRoot($render);
}