forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
15 lines
627 B
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',
|
|
];
|
|
}
|
|
}
|