Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / ENTITY_TYPE_view.twig
1 /**
2  * Implements hook_ENTITY_TYPE_view().
3  */
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',
12     ];
13   }
14 }