Example #1
0
 /**
  * Constructor
  *
  * @param array $config Array of configuration options.
  */
 private final function __construct($config = array())
 {
     //Create the class registry
     if (isset($config['cache_enabled']) && $config['cache_enabled'] && ClassRegistryCache::isSupported()) {
         $this->_registry = new ClassRegistryCache();
         if (isset($config['cache_prefix'])) {
             $this->_registry->setNamespace($config['cache_prefix']);
         }
     } else {
         $this->_registry = new ClassRegistry();
     }
     //Register the library locator
     $this->registerLocator(new ClassLocatorLibrary());
     //Register the Nooku\Library namesoace
     $this->getLocator('lib')->registerNamespace(__NAMESPACE__, dirname(dirname(__FILE__)));
     //Register the loader with the PHP autoloader
     $this->register();
     //Register the component locator
     $this->registerLocator(new ClassLocatorComponent());
     //Register the standard locator
     $this->registerLocator(new ClassLocatorStandard());
 }
Example #2
0
 /**
  * Enable or disable the cache
  *
  * @param bool $cache True or false.
  * @param string $namespace The cache namespace
  * @return ClassLoaderInterface
  */
 public function setCache($cache, $namespace = null)
 {
     if ($cache && ClassRegistryCache::isSupported()) {
         $this->__registry = new ClassRegistryCache();
         if ($namespace) {
             $this->__registry->setNamespace($namespace);
         }
     } else {
         if (!$this->__registry instanceof ClassRegistry) {
             $this->__registry = new ClassRegistry();
         }
     }
     return $this;
 }