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