You are here

function _configuration_export_minimize_dependencies in Configuration Management 7

Iterates over a list of dependencies and kills modules that are captured by other modules 'higher up'.

1 call to _configuration_export_minimize_dependencies()
dependencies_configuration_export in includes/configuration.features.inc
Implements hook_configuration_export().

File

./configuration.export.inc, line 65

Code

function _configuration_export_minimize_dependencies($dependencies, $module_name = '') {

  // Ensure that the module doesn't depend upon itself
  if (!empty($module_name) && !empty($dependencies[$module_name])) {
    unset($dependencies[$module_name]);
  }

  // Do some cleanup:
  // - Remove modules required by Drupal core.
  // - Protect against direct circular dependencies.
  // - Remove "intermediate" dependencies.
  $required = drupal_required_modules();
  foreach ($dependencies as $k => $v) {
    if (empty($v) || in_array($v, $required)) {
      unset($dependencies[$k]);
    }
    else {
      $module = configuration_get_modules($v);
      if ($module && !empty($module->info['dependencies'])) {

        // If this dependency depends on the module itself, we have a circular dependency.
        // Don't let it happen. Only you can prevent forest fires.
        if (in_array($module_name, $module->info['dependencies'])) {
          unset($dependencies[$k]);
        }
        else {
          foreach ($module->info['dependencies'] as $j => $dependency) {
            if (array_search($dependency, $dependencies) !== FALSE) {
              $position = array_search($dependency, $dependencies);
              unset($dependencies[$position]);
            }
          }
        }
      }
    }
  }
  return drupal_map_assoc(array_unique($dependencies));
}