ServiceFactory.php in X Autoload 7.2
Same filename and directory in other branches
File
lib/ServiceFactory.phpView source
<?php
class xautoload_ServiceFactory {
protected $config;
function __construct($config = array()) {
$this->config = $config;
}
function classLoader($registry) {
$finder = $registry->cachedClassFinder;
return new xautoload_ClassLoader($finder);
}
function cachedClassFinder($registry) {
$apc_prefix = $this
->_apcPrefix();
if (!empty($apc_prefix) && FALSE) {
$finder = $registry->classFinder;
return new xautoload_ClassFinder_ApcCache($finder, $apc_prefix);
}
else {
return $registry->classFinder;
}
}
protected function _apcPrefix() {
if (extension_loaded('apc') && function_exists('apc_store') && !empty($GLOBALS['databases'])) {
return 'drupal_xautoload_' . hash('sha256', serialize($GLOBALS['databases']));
}
}
function classFinder($registry) {
if (version_compare(PHP_VERSION, '5.3') >= 0) {
// Create the finder with namespace support.
$finder = new xautoload_ClassFinder_NamespaceOrPrefix();
// D8-style autoloading.
$drupal_psr0 = $registry->drupalNamespacePlugin;
$finder
->registerNamespacePlugin('Drupal', $drupal_psr0);
}
else {
// If we are not at PHP 5.3 +, we can't have namespaces support.
$finder = new xautoload_ClassFinder_Prefix();
}
// Register the xautoload-style PHP 5.2 compatibility solution.
$drupal_prefix = $registry->drupalPrefixPlugin;
$finder
->registerPrefixPlugin('', $drupal_prefix);
return $finder;
}
function drupalPrefixPlugin($registry) {
$system = $registry->drupalExtensionSystem;
return new xautoload_Plugin_DrupalExtensionLibPrefixDeep($system);
}
function drupalNamespacePlugin($registry) {
$system = $registry->drupalExtensionSystem;
return new xautoload_Plugin_DrupalExtensionLibPSR0($system);
}
function drupalExtensionSystem() {
return new xautoload_DrupalExtensionSystem();
}
}
Classes
Name | Description |
---|---|
xautoload_ServiceFactory |