function xautoload_LoaderFactory::buildLoader in X Autoload 7.3
Build a loader for a given mode.
Parameters
string $mode: Loader mode, e.g. 'apc' or 'default'.
Return value
xautoload_ClassLoader_Interface The class loader.
File
- lib/
LoaderFactory.php, line 53
Class
- xautoload_LoaderFactory
- This thing has an overview of available class loaders with different cache mechanics. It can detect the currently applicable cache method, and it can switch between cache methods.
Code
function buildLoader($mode) {
switch ($mode) {
case 'apc_lazy':
if (isset($this->apcPrefix)) {
// Create a loader that uses the proxy finder.
$loader = new xautoload_ClassLoader_ApcCache($this->proxyFinder, $this->apcPrefix);
// Give the loader the real finder, once the proxy fires.
$this->proxyFinder
->proxyObserveInstantiation(array(
$loader,
'setFinder',
));
// Return the loader.
return $loader;
}
break;
case 'apc':
if (isset($this->apcPrefix)) {
/**
* @var xautoload_ClassFinder_Interface
*/
$finder = $this->proxyFinder
->proxyGetInstance();
return new xautoload_ClassLoader_ApcCache($finder, $this->apcPrefix);
}
break;
case 'default':
case 'dev':
default:
/**
* @var xautoload_ClassFinder_Interface
*/
$finder = $this->proxyFinder
->proxyGetInstance();
return new xautoload_ClassLoader_NoCache($finder);
}
// Loader could not be created, because the respective cache mechanic is not available.
return FALSE;
}