public function ModuleHandler::buildModuleDependencies in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
Determines which modules require and are required by each module.
Parameters
array $modules: An array of module objects keyed by module name. Each object contains information discovered during a Drupal\Core\Extension\ExtensionDiscovery scan.
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.
Overrides ModuleHandlerInterface::buildModuleDependencies
See also
\Drupal\Core\Extension\ExtensionDiscovery
File
- core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 220 - Contains \Drupal\Core\Extension\ModuleHandler.
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
public function buildModuleDependencies(array $modules) {
foreach ($modules as $module) {
$graph[$module
->getName()]['edges'] = array();
if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependency) {
$dependency_data = static::parseDependency($dependency);
$graph[$module
->getName()]['edges'][$dependency_data['name']] = $dependency_data;
}
}
}
$graph_object = new Graph($graph);
$graph = $graph_object
->searchAndSort();
foreach ($graph as $module_name => $data) {
$modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
$modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : array();
$modules[$module_name]->sort = $data['weight'];
}
return $modules;
}