protected NodeViewBuilder::alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
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/node/src/NodeViewBuilder.php, line 145
Class
- NodeViewBuilder
- View builder handler for nodes.
Namespace
Drupal\node
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | protected function alterBuild( array & $build , EntityInterface $entity , EntityViewDisplayInterface $display , $view_mode ) { /** @var \Drupal\node\NodeInterface $entity */ parent::alterBuild( $build , $entity , $display , $view_mode ); if ( $entity ->id()) { if ( $entity ->isDefaultRevision()) { $build [ '#contextual_links' ][ 'node' ] = [ 'route_parameters' => [ 'node' => $entity ->id()], 'metadata' => [ 'changed' => $entity ->getChangedTime()], ]; } else { $build [ '#contextual_links' ][ 'node_revision' ] = [ 'route_parameters' => [ 'node' => $entity ->id(), 'node_revision' => $entity ->getRevisionId(), ], 'metadata' => [ 'changed' => $entity ->getChangedTime()], ]; } } } |
Please login to continue.