You are here

protected function EntityRenderHandler::getBlockMinimalBuildArray in Acquia Lift Connector 8.4

Renders block using BlockViewBuilder.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $object: The Content Entity Object.

string $view_mode: The request view mode identifier.

Return value

array Render array for the block.

1 call to EntityRenderHandler::getBlockMinimalBuildArray()
EntityRenderHandler::getViewModeMinimalHtml in modules/acquia_lift_publisher/src/EventSubscriber/Cdf/EntityRenderHandler.php
Get view mode minimal HTML.

File

modules/acquia_lift_publisher/src/EventSubscriber/Cdf/EntityRenderHandler.php, line 331

Class

EntityRenderHandler
Class EntityRenderHandler.

Namespace

Drupal\acquia_lift_publisher\EventSubscriber\Cdf

Code

protected function getBlockMinimalBuildArray(ContentEntityInterface $object, $view_mode) {

  /** @var \Drupal\block_content\Plugin\Block\BlockContentBlock $block */
  $block = $this->blockManager
    ->createInstance('block_content:' . $object
    ->uuid());
  $build = [
    '#theme' => 'block',
    '#attributes' => [],
    '#contextual_links' => [],
    '#weight' => 0,
    '#configuration' => $block
      ->getConfiguration(),
    '#plugin_id' => $block
      ->getPluginId(),
    '#base_plugin_id' => $block
      ->getBaseId(),
    '#derivative_plugin_id' => $block
      ->getDerivativeId(),
  ];

  // Label controlled by the block__block_content__acquia_contenthub template
  // (hidden by default). Override the template in your theme to render a
  // block label.
  if ($build['#configuration']['label'] === '') {
    $build['#configuration']['label'] = $object
      ->label();
  }

  // Block entity itself doesn't have configuration.
  $block
    ->setConfigurationValue('view_mode', $view_mode);
  $build['#configuration']['view_mode'] = $view_mode;

  // See \Drupal\block\BlockViewBuilder::preRender() for reference.
  $content = $this
    ->getViewMode($object, $view_mode);
  if ($content !== NULL && !Element::isEmpty($content)) {
    foreach ([
      '#attributes',
      '#contextual_links',
    ] as $property) {
      if (isset($content[$property])) {
        $build[$property] += $content[$property];
        unset($content[$property]);
      }
    }
  }
  $build['content'] = $content;
  return $build;
}