Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_view_display_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_display_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_view_display_alter.twig
new file mode 100644 (file)
index 0000000..df17a78
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * Implements hook_entity_view_display_alter().
+ */
+function {{ machine_name }}_entity_view_display_alter(\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, array $context) {
+  // Leave field labels out of the search index.
+  if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
+    foreach ($display->getComponents() as $name => $options) {
+      if (isset($options['label'])) {
+        $options['label'] = 'hidden';
+        $display->setComponent($name, $options);
+      }
+    }
+  }
+}