PHP Class Webiny\Component\ClassLoader\ClassLoader

Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Méthodes publiques

Méthode Description
findClass ( string $class ) : string | boolean Tries to get the path to the class based on registered maps.
getClass ( string $class ) : boolean Tries to find the class file based on currently registered rules.
getClassFromCache ( string $class ) : boolean First tries to find the class in the cache. If the class is not found in the cache, then it tries to find it by using the registered maps.
getInstance ( ) Get an instance of ClassLoader.
registerCacheDriver ( CacheStorage $cache ) Sets a cache layer in front of the autoloader.
registerMap ( array $maps ) Register a namespace or PEAR map rule.
unregisterMap ( string $mapPrefix ) : boolean Removes the given map prefix from class loader.

Private Methods

Méthode Description
__construct ( ) Base constructor.
registerAutoloader ( ) Registers SPL autoload function.

Method Details

findClass() public méthode

Tries to get the path to the class based on registered maps.
public findClass ( string $class ) : string | boolean
$class string The name of the class
Résultat string | boolean The path, if found, or false.

getClass() public méthode

Tries to find the class file based on currently registered rules.
public getClass ( string $class ) : boolean
$class string Name of the class you are trying to find.
Résultat boolean True is returned if the class if found and loaded into memory.

getClassFromCache() public méthode

First tries to find the class in the cache. If the class is not found in the cache, then it tries to find it by using the registered maps.
public getClassFromCache ( string $class ) : boolean
$class string Name of the class you are trying to find.
Résultat boolean True is retuned if the class if found and loaded into memory.

getInstance() public static méthode

Get an instance of ClassLoader.
public static getInstance ( )

registerCacheDriver() public méthode

Unregister the old ClassLoader::getClass autoload method.
public registerCacheDriver ( CacheStorage $cache )
$cache Webiny\Component\Cache\CacheStorage Instance of the \Webiny\Component\Cache\Cache class.

registerMap() public méthode

NOTE: PEAR rules must end with an underline '_'.
public registerMap ( array $maps )
$maps array - Array of maps rules. An example rule is ['Webiny' => '/var/WebinyFramework/library']

unregisterMap() public méthode

Removes the given map prefix from class loader.
public unregisterMap ( string $mapPrefix ) : boolean
$mapPrefix string Map prefix that should be removed.
Résultat boolean Returns true if the map prefix was found and removed, otherwise false.