You are here

public function PanelizerNode::alterBuild in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::alterBuild()
  2. 8.3 src/Plugin/PanelizerEntity/PanelizerNode.php \Drupal\panelizer\Plugin\PanelizerEntity\PanelizerNode::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/PanelizerNode.php, line 48

Class

PanelizerNode
Panelizer entity plugin for integrating with nodes.

Namespace

Drupal\panelizer\Plugin\PanelizerEntity

Code

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

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