Composer\Autoload

ClassLoader::add()publicWPSCache 1.0

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

Метод класса: ClassLoader{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ClassLoader = new ClassLoader();
$ClassLoader->add( $prefix, $paths, $prepend );
$prefix(строка) (обязательный)
The prefix
$paths(list|строка) (обязательный)
The PSR-0 root directories
$prepend(true|false)
Whether to prepend the directories
По умолчанию: false

Код ClassLoader::add() WPSCache 1.12.0

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
        );
    }
}