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.
Method of the class: ClassLoader{}
No Hooks.
Return
null
. Nothing (null).
Usage
$ClassLoader = new ClassLoader(); $ClassLoader->add( $prefix, $paths, $prepend );
- $prefix(string) (required)
- The prefix
- $paths(list
|string) (required) - The PSR-0 root directories
- $prepend(true|false)
- Whether to prepend the directories
Default: false
ClassLoader::add() ClassLoader::add code WPSCache 1.12.4
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 ); } }