Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_storage_purge.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_storage_purge.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_storage_purge.twig
new file mode 100644 (file)
index 0000000..4d9d015
--- /dev/null
@@ -0,0 +1,17 @@
+/**
+ * Implements hook_field_storage_purge().
+ */
+function {{ machine_name }}_field_storage_purge($entity_type, $entity, $field, $instance) {
+  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+
+  $table_name = _field_sql_storage_tablename($field);
+  $revision_name = _field_sql_storage_revision_tablename($field);
+  db_delete($table_name)
+    ->condition('entity_type', $entity_type)
+    ->condition('entity_id', $id)
+    ->execute();
+  db_delete($revision_name)
+    ->condition('entity_type', $entity_type)
+    ->condition('entity_id', $id)
+    ->execute();
+}