TYPO3
7.6
|
Public Member Functions | |
getPrefixes () | |
getPrefixesPsr4 () | |
getFallbackDirs () | |
getFallbackDirsPsr4 () | |
getClassMap () | |
addClassMap (array $classMap) | |
add ($prefix, $paths, $prepend=false) | |
addPsr4 ($prefix, $paths, $prepend=false) | |
set ($prefix, $paths) | |
setPsr4 ($prefix, $paths) | |
setUseIncludePath ($useIncludePath) | |
getUseIncludePath () | |
setClassMapAuthoritative ($classMapAuthoritative) | |
isClassMapAuthoritative () | |
register ($prepend=false) | |
unregister () | |
loadClass ($class) | |
findFile ($class) | |
Private Member Functions | |
findFileWithExtension ($class, $ext) | |
Private Attributes | |
$prefixLengthsPsr4 = array() | |
$prefixDirsPsr4 = array() | |
$fallbackDirsPsr4 = array() | |
$prefixesPsr0 = array() | |
$fallbackDirsPsr0 = array() | |
$useIncludePath = false | |
$classMap = array() | |
$classMapAuthoritative = false | |
ClassLoader implements a PSR-0 class loader
See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
$loader = new \Composer\Autoload\ClassLoader(); // register classes with namespaces $loader->add('Symfony\Component', __DIR__.'/component'); $loader->add('Symfony', __DIR__.'/framework'); // activate the autoloader $loader->register(); // to enable searching the include path (eg. for PEAR packages) $loader->setUseIncludePath(true);
In this example, if you try to use a class in the Symfony namespace or one of its children (Symfony for instance), the autoloader will first look for the class under the component/ directory, and it will then fallback to the framework/ directory if not found before giving up.
This class is loosely based on the Symfony UniversalClassLoader.
Definition at line 43 of file ClassLoader.php.
add | ( | $prefix, | |
$paths, | |||
$prepend = false |
|||
) |
Registers a set of PSR-0 directories for a given prefix, either appending or prepending to the ones previously set for this prefix.
string | $prefix | The prefix |
array | string | $paths | The PSR-0 root directories |
bool | $prepend | Whether to prepend the directories |
Definition at line 108 of file ClassLoader.php.
addClassMap | ( | array | $classMap | ) |
array | $classMap | Class to filename map |
Definition at line 91 of file ClassLoader.php.
References ClassLoader\$classMap.
addPsr4 | ( | $prefix, | |
$paths, | |||
$prepend = false |
|||
) |
Registers a set of PSR-4 directories for a given namespace, either appending or prepending to the ones previously set for this namespace.
string | $prefix | The prefix/namespace, with trailing '\' |
array | string | $paths | The PSR-0 base directories |
bool | $prepend | Whether to prepend the directories |
\InvalidArgumentException |
Definition at line 155 of file ClassLoader.php.
References elseif.
findFile | ( | $class | ) |
Finds the path to the file where the class is defined.
string | $class | The name of the class |
Definition at line 314 of file ClassLoader.php.
References ClassLoader\findFileWithExtension().
Referenced by ClassLoader\loadClass().
|
private |
Definition at line 344 of file ClassLoader.php.
Referenced by ClassLoader\findFile().
getClassMap | ( | ) |
Definition at line 83 of file ClassLoader.php.
References ClassLoader\$classMap.
getFallbackDirs | ( | ) |
Definition at line 73 of file ClassLoader.php.
References ClassLoader\$fallbackDirsPsr0.
getFallbackDirsPsr4 | ( | ) |
Definition at line 78 of file ClassLoader.php.
References ClassLoader\$fallbackDirsPsr4.
getPrefixes | ( | ) |
Definition at line 59 of file ClassLoader.php.
getPrefixesPsr4 | ( | ) |
Definition at line 68 of file ClassLoader.php.
References ClassLoader\$prefixDirsPsr4.
getUseIncludePath | ( | ) |
Can be used to check if the autoloader uses the include path to check for classes.
Definition at line 248 of file ClassLoader.php.
References ClassLoader\$useIncludePath.
isClassMapAuthoritative | ( | ) |
Should class lookup fail if not found in the current class map?
Definition at line 269 of file ClassLoader.php.
References ClassLoader\$classMapAuthoritative.
loadClass | ( | $class | ) |
Loads the given class or interface.
string | $class | The name of the class |
Definition at line 298 of file ClassLoader.php.
References ClassLoader\findFile(), and Composer\Autoload\includeFile().
register | ( | $prepend = false | ) |
Registers this instance as an autoloader.
bool | $prepend | Whether to prepend the autoloader or not |
Definition at line 279 of file ClassLoader.php.
set | ( | $prefix, | |
$paths | |||
) |
Registers a set of PSR-0 directories for a given prefix, replacing any others previously set for this prefix.
string | $prefix | The prefix |
array | string | $paths | The PSR-0 base directories |
Definition at line 200 of file ClassLoader.php.
setClassMapAuthoritative | ( | $classMapAuthoritative | ) |
Turns off searching the prefix and fallback directories for classes that have not been registered with the class map.
bool | $classMapAuthoritative |
Definition at line 259 of file ClassLoader.php.
References ClassLoader\$classMapAuthoritative.
setPsr4 | ( | $prefix, | |
$paths | |||
) |
Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace.
string | $prefix | The prefix/namespace, with trailing '\' |
array | string | $paths | The PSR-4 base directories |
\InvalidArgumentException |
Definition at line 218 of file ClassLoader.php.
setUseIncludePath | ( | $useIncludePath | ) |
Turns on searching the include path for class files.
bool | $useIncludePath |
Definition at line 237 of file ClassLoader.php.
References ClassLoader\$useIncludePath.
unregister | ( | ) |
Unregisters this instance as an autoloader.
Definition at line 287 of file ClassLoader.php.
|
private |
Definition at line 55 of file ClassLoader.php.
Referenced by ClassLoader\addClassMap(), and ClassLoader\getClassMap().
|
private |
Definition at line 57 of file ClassLoader.php.
Referenced by ClassLoader\isClassMapAuthoritative(), and ClassLoader\setClassMapAuthoritative().
|
private |
Definition at line 52 of file ClassLoader.php.
Referenced by ClassLoader\getFallbackDirs().
|
private |
Definition at line 48 of file ClassLoader.php.
Referenced by ClassLoader\getFallbackDirsPsr4().
|
private |
Definition at line 47 of file ClassLoader.php.
Referenced by ClassLoader\getPrefixesPsr4().
|
private |
Definition at line 51 of file ClassLoader.php.
|
private |
Definition at line 46 of file ClassLoader.php.
|
private |
Definition at line 54 of file ClassLoader.php.
Referenced by ClassLoader\getUseIncludePath(), and ClassLoader\setUseIncludePath().