You are here

protected function BlockContentViewBuilder::alterBuild in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block_content/src/BlockContentViewBuilder.php \Drupal\block_content\BlockContentViewBuilder::alterBuild()

Specific per-entity building.

Parameters

array $build: The render array that is being created.

\Drupal\Core\Entity\EntityInterface $entity: The entity to be prepared.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The entity view display holding the display options configured for the entity components.

string $view_mode: The view mode that should be used to prepare the entity.

Overrides EntityViewBuilder::alterBuild

File

core/modules/block_content/src/BlockContentViewBuilder.php, line 52
Contains \Drupal\block_content\BlockContentViewBuilder.

Class

BlockContentViewBuilder
Render controller for custom blocks.

Namespace

Drupal\block_content

Code

protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  parent::alterBuild($build, $entity, $display, $view_mode);

  // Add contextual links for this custom block.
  if (!$entity
    ->isNew()) {
    $build['#contextual_links']['block_content'] = array(
      'route_parameters' => array(
        'block_content' => $entity
          ->id(),
      ),
      'metadata' => array(
        'changed' => $entity
          ->getChangedTime(),
      ),
    );
  }
}