PHP Class Webiny\Component\ClassLoader\ClassLoader

Datei anzeigen Open project: Webiny/Framework Class Usage Examples

Public Methods

Method 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

Method Description
__construct ( ) Base constructor.
registerAutoloader ( ) Registers SPL autoload function.

Method Details

findClass() public method

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
return string | boolean The path, if found, or false.

getClass() public method

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.
return boolean True is returned if the class if found and loaded into memory.

getClassFromCache() public method

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.
return boolean True is retuned if the class if found and loaded into memory.

getInstance() public static method

Get an instance of ClassLoader.
public static getInstance ( )

registerCacheDriver() public method

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 method

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 method

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