Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_bundle_field_info.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_bundle_field_info.twig
new file mode 100644 (file)
index 0000000..001f0d8
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * Implements hook_entity_bundle_field_info().
+ */
+function {{ machine_name }}_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
+  // Add a property only to nodes of the 'article' bundle.
+  if ($entity_type->id() == 'node' && $bundle == 'article') {
+    $fields = [];
+    $fields['mymodule_text_more'] = BaseFieldDefinition::create('string')
+      ->setLabel(t('More text'))
+      ->setComputed(TRUE)
+      ->setClass('\Drupal\mymodule\EntityComputedMoreText');
+    return $fields;
+  }
+}