v1/vendor/chi-teck/drupal-code-generator/templates/hook/entity_view.twig

15 lines
627 B
Twig

/**
* Implements hook_entity_view().
*/
function {{ machine_name }}_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
// Only do the extra work if the component is configured to be displayed.
// This assumes a 'mymodule_addition' extra field has been defined for the
// entity bundle in hook_entity_extra_field_info().
if ($display->getComponent('mymodule_addition')) {
$build['mymodule_addition'] = [
'#markup' => mymodule_addition($entity),
'#theme' => 'mymodule_my_additional_field',
];
}
}