You are here

function features_modules_enabled in Features 7.2

Same name and namespace in other branches
  1. 7 features.module \features_modules_enabled()

Implements hook_modules_enabled().

File

./features.module, line 407
Main *.module file for the 'features' module.

Code

function features_modules_enabled($modules) {

  // Allow distributions to disable this behavior and rebuild the features
  // manually inside a batch.
  if (!variable_get('features_rebuild_on_module_install', TRUE)) {
    return;
  }

  // Mark modules as being changed for test in features_flush_caches.
  variable_set('features_modules_changed', TRUE);

  // Go through all modules and gather features that can be enabled.
  $items = array();
  foreach ($modules as $module) {
    if ($feature = features_load_feature($module)) {
      $items[$module] = array_keys($feature->info['features']);
    }
  }
  if (!empty($items)) {

    // Need to include any new files.
    // @todo Redo function so can take in list of modules to include.
    features_include_defaults(NULL, TRUE);
    _features_restore('enable', $items);

    // Rebuild the list of features includes.
    features_include(TRUE);

    // Reorders components to match hook order and removes non-existant.
    $all_components = array_keys(features_get_components());
    foreach ($items as $module => $components) {
      $items[$module] = array_intersect($all_components, $components);
    }
    _features_restore('rebuild', $items);
  }
}