Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_extra_field_info.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_extra_field_info.twig
new file mode 100644 (file)
index 0000000..9badf0a
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Implements hook_entity_extra_field_info().
+ */
+function {{ machine_name }}_entity_extra_field_info() {
+  $extra = [];
+  $module_language_enabled = \Drupal::moduleHandler()->moduleExists('language');
+  $description = t('Node module element');
+
+  foreach (NodeType::loadMultiple() as $bundle) {
+
+    // Add also the 'language' select if Language module is enabled and the
+    // bundle has multilingual support.
+    // Visibility of the ordering of the language selector is the same as on the
+    // node/add form.
+    if ($module_language_enabled) {
+      $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->id());
+      if ($configuration->isLanguageAlterable()) {
+        $extra['node'][$bundle->id()]['form']['language'] = [
+          'label' => t('Language'),
+          'description' => $description,
+          'weight' => 0,
+        ];
+      }
+    }
+    $extra['node'][$bundle->id()]['display']['language'] = [
+      'label' => t('Language'),
+      'description' => $description,
+      'weight' => 0,
+      'visible' => FALSE,
+    ];
+  }
+
+  return $extra;
+}