protected function ModuleEnable::moduleEnableCheckDependencies in X Autoload 7.5
Parameters
string[] $module_list:
Return value
string[] Module list with added dependencies, sorted by dependency.
Throws
\Exception
1 call to ModuleEnable::moduleEnableCheckDependencies()
- ModuleEnable::moduleEnable in tests/
src/ VirtualDrupal/ ModuleEnable.php - Simulates Drupal's module_enable()
File
- tests/
src/ VirtualDrupal/ ModuleEnable.php, line 136
Class
Namespace
Drupal\xautoload\Tests\VirtualDrupalCode
protected function moduleEnableCheckDependencies(array $module_list) {
// Get all module data so we can find dependencies and sort.
$module_data = $this->systemRebuildModuleData
->systemRebuildModuleData();
// Create an associative array with weights as values.
$module_list = array_flip(array_values($module_list));
// The array is iterated over manually (instead of using a foreach) because
// modules may be added to the list within the loop and we need to process
// them.
while ($module = key($module_list)) {
next($module_list);
if (!isset($module_data[$module])) {
// This module is not found in the filesystem, abort.
throw new \Exception("Module '{$module}' not found.");
}
if ($module_data[$module]->status) {
// Skip already enabled modules.
unset($module_list[$module]);
continue;
}
$module_list[$module] = $module_data[$module]->sort;
// Add dependencies to the list, with a placeholder weight.
// The new modules will be processed as the while loop continues.
foreach (array_keys($module_data[$module]->requires) as $dependency) {
if (!isset($module_list[$dependency])) {
$module_list[$dependency] = 0;
}
}
}
if (!$module_list) {
// Nothing to do. All modules already enabled.
return array();
}
// Sort the module list by pre-calculated weights.
arsort($module_list);
return array_keys($module_list);
}