Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / entity_insert.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/entity_insert.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/entity_insert.twig
new file mode 100644 (file)
index 0000000..261e307
--- /dev/null
@@ -0,0 +1,16 @@
+/**
+ * Implements hook_entity_insert().
+ */
+function {{ machine_name }}_entity_insert($entity, $type) {
+  // Insert the new entity into a fictional table of all entities.
+  $info = entity_get_info($type);
+  list($id) = entity_extract_ids($type, $entity);
+  db_insert('example_entity')
+    ->fields(array(
+      'type' => $type,
+      'id' => $id,
+      'created' => REQUEST_TIME,
+      'updated' => REQUEST_TIME,
+    ))
+    ->execute();
+}