public function ModuleHandler::buildModuleDependencies in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
- 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
File
- core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 223
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'] = [];
if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependency) {
$dependency_data = Dependency::createFromString($dependency);
$graph[$module
->getName()]['edges'][$dependency_data
->getName()] = $dependency_data;
}
}
}
$graph_object = new Graph($graph);
$graph = $graph_object
->searchAndSort();
foreach ($graph as $module_name => $data) {
$modules[$module_name]->required_by = $data['reverse_paths'] ?? [];
$modules[$module_name]->requires = $data['paths'] ?? [];
$modules[$module_name]->sort = $data['weight'];
}
return $modules;
}