DrupalKernel::classLoaderAddMultiplePsr4

protected DrupalKernel::classLoaderAddMultiplePsr4(array $namespaces = array(), $class_loader = NULL)

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.

File

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

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected function classLoaderAddMultiplePsr4(array $namespaces = array(), $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);
  }
}
doc_Drupal
2016-10-29 09:02:58
Comments
Leave a Comment

Please login to continue.