Browse Source

Added a hook_bundle_delete hook

Stephen Ficklin 8 years ago
parent
commit
e578dd2c87
2 changed files with 17 additions and 0 deletions
  1. 10 0
      tripal/api/tripal.entities.api.inc
  2. 7 0
      tripal/includes/TripalBundleController.inc

+ 10 - 0
tripal/api/tripal.entities.api.inc

@@ -160,6 +160,16 @@ function tripal_load_bundle_entity($values) {
   return NULL;
 }
 
+
+/**
+ * Allows a module to perform tasks before a TripalBundle object is deleted.
+ *
+ * @param $bundle
+ *   The newly created TripalBundle object.
+ */
+function hook_bundle_delete($bundle) {
+
+}
 /**
  * Allows a module to perform tasks after a TripalBundle object is created.
  *

+ 7 - 0
tripal/includes/TripalBundleController.inc

@@ -55,6 +55,13 @@ class TripalBundleController extends EntityAPIControllerExportable {
 
       foreach ($bundles as $id => $bundle) {
 
+        // Allow modules to perform actions when the bundle is deleted.
+        $modules = module_implements('bundle_delete');
+        foreach ($modules as $module) {
+          $function = $module . '_bundle_delete';
+          $function($bundle);
+        }
+
         // Find any TripalEntity fields that are attached to this bundle and
         // remove them.
         $instances = field_info_instances('TripalEntity', $bundle->name);