Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / ENTITY_TYPE_insert.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_insert.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/ENTITY_TYPE_insert.twig
new file mode 100644 (file)
index 0000000..1d639ba
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * Implements hook_ENTITY_TYPE_insert().
+ */
+function {{ machine_name }}_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
+  // Insert the new entity into a fictional table of this type of entity.
+  db_insert('example_entity')
+    ->fields([
+      'id' => $entity->id(),
+      'created' => REQUEST_TIME,
+      'updated' => REQUEST_TIME,
+    ])
+    ->execute();
+}