function ModuleHandler::buildModuleDependencies
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
- 8.9.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
- 10 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::buildModuleDependencies()
Overrides ModuleHandlerInterface::buildModuleDependencies
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 212
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.