Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_view.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view.twig
new file mode 100644 (file)
index 0000000..57b5f9b
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * 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',
+    ];
+  }
+}