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_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_view_alter.twig
new file mode 100644 (file)
index 0000000..3c814b2
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * Implements hook_ENTITY_TYPE_view_alter().
+ */
+function {{ machine_name }}_ENTITY_TYPE_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
+  if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
+    // Change its weight.
+    $build['an_additional_field']['#weight'] = -10;
+
+    // Add a #post_render callback to act on the rendered HTML of the entity.
+    $build['#post_render'][] = 'my_module_node_post_render';
+  }
+}