You are here

public function PanelizerTerm::alterBuild in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/PanelizerEntity/PanelizerTerm.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerTerm::alterBuild()
  2. 8.4 src/Plugin/PanelizerEntity/PanelizerTerm.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerTerm::alterBuild()

Alter the built entity view in an entity specific way before rendering.

This is useful for adding things like contextual links.

Parameters

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

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

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels display used to render this entity.

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

Overrides PanelizerEntityBase::alterBuild

File

src/Plugin/PanelizerEntity/PanelizerTerm.php, line 40

Class

PanelizerTerm
Panelizer entity plugin for integrating with taxonomy terms.

Namespace

Drupal\panelizer\Plugin\PanelizerEntity

Code

public function alterBuild(array &$build, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) {

  /** @var $entity \Drupal\taxonomy\Entity\Term */
  parent::alterBuild($build, $entity, $panels_display, $view_mode);
  if ($entity
    ->id()) {
    $build['#contextual_links']['taxonomy_term'] = [
      'route_parameters' => [
        'taxonomy_term' => $entity
          ->id(),
      ],
      'metadata' => [
        'changed' => $entity
          ->getChangedTime(),
      ],
    ];
  }
}