Elgg  Version 6.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\AutoloadManager Class Reference

Manages core autoloading and caching of class maps. More...

Public Member Functions

 __construct (protected\Elgg\ClassLoader $loader,\Elgg\Config $config,\Elgg\Cache\BaseCache $cache)
 Constructor. More...
 
 addClasses ($dir)
 Add classes found in this directory to the class map and allow classes in subdirectories to be found by PSR-0 rules. More...
 
 saveCache ()
 If necessary, save necessary state details. More...
 
 loadCache ()
 Set the state of the manager from the cache. More...
 
 deleteCache ()
 Delete the cache file. More...
 
 getLoader ()
 Get the class loader. More...
 

Public Attributes

const FILENAME = 'autoload_data.php'
 
const KEY_CLASSES = 'classes'
 
const KEY_SCANNED_DIRS = 'scannedDirs'
 

Protected Member Functions

 scanClassesDir ($dir)
 Scan (non-recursively) a /classes directory for PHP files to map directly to classes. More...
 
 getCacheFileContents ()
 Tries to read the contents of the cache file and if valid returns the content. More...
 

Protected Attributes

array $scannedDirs = []
 
bool $altered = false
 

Detailed Description

Manages core autoloading and caching of class maps.

Definition at line 12 of file AutoloadManager.php.

Constructor & Destructor Documentation

Elgg\AutoloadManager::__construct ( protected\Elgg\ClassLoader  $loader,
\Elgg\Config  $config,
\Elgg\Cache\BaseCache  $cache 
)

Constructor.

Parameters
\Elgg\ClassLoader$loaderClass loader object
\Elgg\Config$configConfig
\Elgg\Cache\BaseCache$cachelocal file cache

Definition at line 37 of file AutoloadManager.php.

Member Function Documentation

Elgg\AutoloadManager::addClasses (   $dir)

Add classes found in this directory to the class map and allow classes in subdirectories to be found by PSR-0 rules.

We keep track of which dirs were scanned on previous requests so we don't need to rescan unless the cache is emptied.

Parameters
string$dirDirectory of classes
Returns

Definition at line 55 of file AutoloadManager.php.

Elgg\AutoloadManager::deleteCache ( )

Delete the cache file.

Returns

Definition at line 178 of file AutoloadManager.php.

Elgg\AutoloadManager::getCacheFileContents ( )
protected

Tries to read the contents of the cache file and if valid returns the content.

Returns
false|array

Definition at line 160 of file AutoloadManager.php.

Elgg\AutoloadManager::getLoader ( )

Get the class loader.

Returns

Definition at line 192 of file AutoloadManager.php.

Elgg\AutoloadManager::loadCache ( )

Set the state of the manager from the cache.

Returns
bool was the cache loaded?

Definition at line 139 of file AutoloadManager.php.

Elgg\AutoloadManager::saveCache ( )

If necessary, save necessary state details.

Returns

Definition at line 109 of file AutoloadManager.php.

Elgg\AutoloadManager::scanClassesDir (   $dir)
protected

Scan (non-recursively) a /classes directory for PHP files to map directly to classes.

For BC with Elgg 1.8's autoloader we map these files directly, but besides this the autoloader is PSR-0 compatible.

Parameters
string$dirDirectory of classes
Returns
array

Definition at line 77 of file AutoloadManager.php.

Member Data Documentation

bool Elgg\AutoloadManager::$altered = false
protected

Definition at line 28 of file AutoloadManager.php.

array Elgg\AutoloadManager::$scannedDirs = []
protected

Definition at line 23 of file AutoloadManager.php.

const Elgg\AutoloadManager::FILENAME = 'autoload_data.php'

Definition at line 16 of file AutoloadManager.php.

const Elgg\AutoloadManager::KEY_CLASSES = 'classes'

Definition at line 17 of file AutoloadManager.php.

const Elgg\AutoloadManager::KEY_SCANNED_DIRS = 'scannedDirs'

Definition at line 18 of file AutoloadManager.php.


The documentation for this class was generated from the following file: