You are here

protected function ModuleExtensionList::ensureRequiredDependencies in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Extension/ModuleExtensionList.php \Drupal\Core\Extension\ModuleExtensionList::ensureRequiredDependencies()
  2. 9 core/lib/Drupal/Core/Extension/ModuleExtensionList.php \Drupal\Core\Extension\ModuleExtensionList::ensureRequiredDependencies()

Marks dependencies of required modules as 'required', recursively.

Parameters

\Drupal\Core\Extension\Extension $module: The module extension object.

\Drupal\Core\Extension\Extension[] $modules: Extension objects for all available modules.

File

core/lib/Drupal/Core/Extension/ModuleExtensionList.php, line 211

Class

ModuleExtensionList
Provides a list of available modules.

Namespace

Drupal\Core\Extension

Code

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);
      }
    }
  }
}