You are here

function rabbit_hole_modules_uninstalled in Rabbit Hole 7.2

Implements hook_modules_uninstalled().

File

./rabbit_hole.module, line 694
Main module file for Rabbit Hole.

Code

function rabbit_hole_modules_uninstalled($modules) {
  foreach ($modules as $module) {

    // If this module implements hook_rabbit_hole(), we should remove the Rabbit
    // Hole fields from the base table of the entity type that this module is
    // altering. We need to include the .module file manually, since the module
    // hsa been uninstalled and therefore, isn't reachable the normal way.
    module_load_include('module', $module);
    $function = $module . '_rabbit_hole';
    if (function_exists($function)) {

      // Gather info about the module, entity and get the Rabbit Hole fields.
      $rabbit_hole_info = $function();
      $entity_info = entity_get_info($rabbit_hole_info[$module]['entity type']);
      $fields = rabbit_hole_schema_fields();

      // Remove each field from the base table for the entity.
      foreach ($fields as $name => $spec) {
        if (db_field_exists($entity_info['base table'], $name)) {
          db_drop_field($entity_info['base table'], $name);
        }
      }

      // Delete any variables that is set the this entity.
      foreach ($entity_info['bundles'] as $bundle => $info) {
        rabbit_hole_delete_variables($rabbit_hole_info[$module]['entity type'], $bundle);
      }
    }
  }
}