Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ClassLoader.php

function ClassLoader::add

Same name in this branch
  1. 11.1.x vendor/composer/composer/src/Composer/Autoload/ClassLoader.php \Composer\Autoload\ClassLoader::add()

Registers a set of PSR-0 directories for a given prefix, either appending or prepending to the ones previously set for this prefix.

Parameters

string $prefix The prefix:

list<string>|string $paths The PSR-0 root directories:

bool $prepend Whether to prepend the directories:

Return value

void

File

vendor/composer/ClassLoader.php, line 180

Class

ClassLoader
ClassLoader implements a PSR-0, PSR-4 and classmap class loader.

Namespace

Composer\Autoload

Code

public function add($prefix, $paths, $prepend = false) {
    $paths = (array) $paths;
    if (!$prefix) {
        if ($prepend) {
            $this->fallbackDirsPsr0 = array_merge($paths, $this->fallbackDirsPsr0);
        }
        else {
            $this->fallbackDirsPsr0 = array_merge($this->fallbackDirsPsr0, $paths);
        }
        return;
    }
    $first = $prefix[0];
    if (!isset($this->prefixesPsr0[$first][$prefix])) {
        $this->prefixesPsr0[$first][$prefix] = $paths;
        return;
    }
    if ($prepend) {
        $this->prefixesPsr0[$first][$prefix] = array_merge($paths, $this->prefixesPsr0[$first][$prefix]);
    }
    else {
        $this->prefixesPsr0[$first][$prefix] = array_merge($this->prefixesPsr0[$first][$prefix], $paths);
    }
}
RSS feed
Powered by Drupal