/**
* Marks dependencies of required modules as 'required', recursively.
*
* @param \Drupal\Core\Extension\Extension $module
* The module extension object.
* @param \Drupal\Core\Extension\Extension[] $modules
* Extension objects for all available modules.
*/
protected function ensureRequiredDependencies(Extension
$module, array
$modules =
[]) { if (!
empty($module->info
['required'
])) { foreach ($module->info
['dependencies'
] as $dependency) { $dependency_name = Dependency::
createFromString($dependency)->
getName();
if (!
isset($modules[$dependency_name]->info
['required'
])) { $modules[$dependency_name]->info
['required'
] = TRUE;
$modules[$dependency_name]->info
['explanation'
] =
$this->
t('Dependency of required module @module',
['@module' =>
$module->info
['name'
]]);
// Ensure any dependencies it has are required.
$this->
ensureRequiredDependencies($modules[$dependency_name],
$modules);
} } } }}