function ModuleHandler::__construct

Constructs a ModuleHandler object.

Parameters

string $root: The app root.

array<string, array{type: string, pathname: string, filename: string}> $module_list: An associative array whose keys are the names of installed modules and whose values are Extension class parameters. This is normally the %container.modules% parameter being set up by DrupalKernel.

\Drupal\Core\KeyValueStore\KeyValueFactoryInterface $keyValueFactory: The key value factory.

\Drupal\Core\Utility\CallableResolver $callableResolver: The callable resolver.

\Drupal\Core\Cache\CacheBackendInterface $cache: The bootstrap cache.

See also

\Drupal\Core\DrupalKernel

\Drupal\Core\CoreServiceProvider

File

core/lib/Drupal/Core/Extension/ModuleHandler.php, line 125

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

public function __construct(protected $root, array $module_list, protected readonly KeyValueFactoryInterface $keyValueFactory, protected readonly CallableResolver $callableResolver, protected readonly CacheBackendInterface $cache) {
  $this->moduleList = [];
  foreach ($module_list as $name => $module) {
    $this->moduleList[$name] = new Extension($this->root, $module['type'], $module['pathname'], $module['filename']);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.