You are here

protected function DrupalKernel::classLoaderAddMultiplePsr4 in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::classLoaderAddMultiplePsr4()

Registers a list of namespaces with PSR-4 directories for class loading.

Parameters

array $namespaces: Array where each key is a namespace like 'Drupal\system', and each value is either a PSR-4 base directory, or an array of PSR-4 base directories associated with this namespace.

object $class_loader: The class loader. Normally \Composer\Autoload\ClassLoader, as included by the front controller, but may also be decorated; e.g., \Symfony\Component\ClassLoader\ApcClassLoader.

3 calls to DrupalKernel::classLoaderAddMultiplePsr4()
DrupalKernel::attachSynthetic in core/lib/Drupal/Core/DrupalKernel.php
Attach synthetic values on to kernel.
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 1490

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function classLoaderAddMultiplePsr4(array $namespaces = [], $class_loader = NULL) {
  if ($class_loader === NULL) {
    $class_loader = $this->classLoader;
  }
  foreach ($namespaces as $prefix => $paths) {
    if (is_array($paths)) {
      foreach ($paths as $key => $value) {
        $paths[$key] = $this->root . '/' . $value;
      }
    }
    elseif (is_string($paths)) {
      $paths = $this->root . '/' . $paths;
    }
    $class_loader
      ->addPsr4($prefix . '\\', $paths);
  }
}