You are here

function rabbit_hole_modules_enabled in Rabbit Hole 7.2

Implements hook_modules_enabled().

File

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

Code

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

    // If this module implements hook_rabbit_hole(), we should add the Rabbit
    // Hole fields to the base table of the entity type that this module is
    // altering.
    $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();

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