Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / entity_field_values_init.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_values_init.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/entity_field_values_init.twig
new file mode 100644 (file)
index 0000000..1d15bc3
--- /dev/null
@@ -0,0 +1,8 @@
+/**
+ * Implements hook_entity_field_values_init().
+ */
+function {{ machine_name }}_entity_field_values_init(\Drupal\Core\Entity\FieldableEntityInterface $entity) {
+  if ($entity instanceof \Drupal\Core\Entity\ContentEntityInterface && !$entity->foo->value) {
+    $entity->foo->value = 'some_initial_value';
+  }
+}