devel_wizard-2.x-dev/templates/spell/entity_type/content/view_builder.php.twig
templates/spell/entity_type/content/view_builder.php.twig
{%
include '@devel_wizard/php/devel_wizard.php.file.header.php.twig'
with {
'namespace': content.namespace,
}
%}
{%-
include '@devel_wizard/php/devel_wizard.php.file.use_statements.php.twig'
with {
'useStatements': {
'Drupal\\Core\\Entity\\Display\\EntityViewDisplayInterface': '',
'Drupal\\Core\\Entity\\EntityInterface': '',
'Drupal\\Core\\Entity\\EntityViewBuilder': '',
},
}
%}
class ViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*
* @phpstan-param array<string, mixed> $build
* @phpstan-param string $view_mode
*/
protected function alterBuild(
array &$build,
EntityInterface $entity,
EntityViewDisplayInterface $display,
$view_mode,
): void {
parent::alterBuild($build, $entity, $display, $view_mode);
$build['#contextual_links'][$entity->getEntityTypeId()] = [
'route_parameters' => [
$entity->getEntityTypeId() => $entity->id(),
],
];
}
}
