function DrupalKernel::getModuleNamespacesPsr4

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getModuleNamespacesPsr4()
  2. 8.9.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getModuleNamespacesPsr4()
  3. 10 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::getModuleNamespacesPsr4()

Gets the PSR-4 base directories for module namespaces.

Parameters

string[] $module_file_names: Array where each key is a module name, and each value is a path to the respective *.info.yml file.

Return value

string[] Array where each key is a module namespace like 'Drupal\system', and each value is the PSR-4 base directory associated with the module namespace.

3 calls to DrupalKernel::getModuleNamespacesPsr4()
DrupalKernel::compileContainer in core/lib/Drupal/Core/DrupalKernel.php
Compiles a new service container.
DrupalKernel::discoverServiceProviders in core/lib/Drupal/Core/DrupalKernel.php
Discovers available serviceProviders.
DrupalKernel::updateModules in core/lib/Drupal/Core/DrupalKernel.php
Implements Drupal\Core\DrupalKernelInterface::updateModules().

File

core/lib/Drupal/Core/DrupalKernel.php, line 1510

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function getModuleNamespacesPsr4($module_file_names) {
    $namespaces = [];
    foreach ($module_file_names as $module => $filename) {
        $namespaces["Drupal\\{$module}"] = dirname($filename) . '/src';
    }
    return $namespaces;
}

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