You are here

function features_install_modules in Features 7.2

Same name and namespace in other branches
  1. 6 features.module \features_install_modules()
  2. 7 features.module \features_install_modules()

Enables an array of (feature) modules and their dependencies.

Modules that are already enabled and installed are ignored. Consider this a helper or extension to module_enable().

Parameters

string[] $modules: An array of module names or dependency strings.

See also

\module_enable()

2 calls to features_install_modules()
dependencies_features_rebuild in includes/features.features.inc
Implements hook_features_rebuild(). Ensure that all of a feature's dependencies are enabled.
features_form_submit in ./features.admin.inc
Submit handler for the 'manage features' form.

File

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

Code

function features_install_modules($modules) {
  variable_set('features_modules_changed', TRUE);
  module_load_include('inc', 'features', 'features.export');
  $files = system_rebuild_module_data();

  // Build maximal list of dependencies.
  $install = array();
  foreach ($modules as $name) {

    // Parse the dependency string into the module name and version information.
    $parsed_name = drupal_parse_dependency($name);
    $name = $parsed_name['name'];
    if ($file = $files[$name]) {
      $install[] = $name;
      if (!empty($file->info['dependencies'])) {
        $install = array_merge($install, _features_export_maximize_dependencies($file->info['dependencies']));
      }
    }
  }

  // Filter out enabled modules.
  $enabled = array_filter($install, 'module_exists');
  $install = array_diff($install, $enabled);
  if (!empty($install)) {

    // Make sure the install API is available.
    $install = array_unique($install);
    include_once DRUPAL_ROOT . '/' . './includes/install.inc';
    module_enable($install);
  }
}