_module_build_dependencies

Versions
6 – 7
_module_build_dependencies($files)

Find dependencies any level deep and fill in required by information too.

Parameters

$files The array of filesystem objects used to rebuild the cache.

Return value

The same array with the new keys for each module:

  • requires: An array with the keys being the modules that this module requires.
  • required_by: An array with the keys being the modules that will not work without this module.

▾ 1 function calls _module_build_dependencies()

system_rebuild_module_data in modules/system/system.module
Rebuild, save, and return data about all currently available modules.

Code

includes/module.inc, line 191

<?php
function _module_build_dependencies($files) {
  require_once DRUPAL_ROOT . '/includes/graph.inc';
  $roots = $files;
  foreach ($files as $filename => $file) {
    $graph[$file->name]['edges'] = array();
    if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
      foreach ($file->info['dependencies'] as $dependency) {
        $dependency_data = drupal_parse_dependency($dependency);
        $graph[$file->name]['edges'][$dependency_data['name']] = $dependency_data;
        unset($roots[$dependency_data['name']]);
      }
    }
  }
  drupal_depth_first_search($graph, array_keys($roots));
  foreach ($graph as $module => $data) {
    $files[$module]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
    $files[$module]->requires = isset($data['paths']) ? $data['paths'] : array();
    $files[$module]->sort = $data['weight'];
  }
  return $files;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.