annotate vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view.twig @ 5:12f9dff5fda9
tip
Update to Drupal core 8.7.1
author |
Chris Cannam |
date |
Thu, 09 May 2019 15:34:47 +0100 |
parents |
c75dbcec494b |
children |
|
rev |
line source |
Chris@0
|
1 /**
|
Chris@0
|
2 * Implements hook_entity_view().
|
Chris@0
|
3 */
|
Chris@0
|
4 function {{ machine_name }}_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
|
Chris@0
|
5 // Only do the extra work if the component is configured to be displayed.
|
Chris@0
|
6 // This assumes a 'mymodule_addition' extra field has been defined for the
|
Chris@0
|
7 // entity bundle in hook_entity_extra_field_info().
|
Chris@0
|
8 if ($display->getComponent('mymodule_addition')) {
|
Chris@0
|
9 $build['mymodule_addition'] = [
|
Chris@0
|
10 '#markup' => mymodule_addition($entity),
|
Chris@0
|
11 '#theme' => 'mymodule_my_additional_field',
|
Chris@0
|
12 ];
|
Chris@0
|
13 }
|
Chris@0
|
14 }
|