예제 #1
0
 public function __construct($keyPrefix = 'class:', $ttl = 60)
 {
     $this->_keyPrefix = $keyPrefix;
     $this->_ttl = $ttl;
     if (\function_exists('apc_fetch')) {
         autoloadManager::getInstance()->registerCacheLoader(array($this, 'loadClass'));
         autoloadManager::getInstance()->registerCache(array($this, 'cache'));
     }
 }
예제 #2
0
 public function loadClass($name)
 {
     foreach ($this->_map as $prefix => $path) {
         if (0 !== \strpos($name, $prefix)) {
             continue;
         }
         if (null !== $this->_path) {
             $path = $this->_path . \DIRECTORY_SEPARATOR . $path;
         }
         $fn = $path . '/' . \str_replace(array('\\', '_', ""), array('/', '/', ''), $name) . '.php';
         if (\is_file($fn)) {
             include $fn;
             autoloadManager::getInstance()->cache($name, $fn);
             return true;
         }
     }
     return false;
 }
예제 #3
0
 public function loadClass($class)
 {
     if ($this->_namespace !== null) {
         if (\substr($class, 0, \strlen($this->_namespace) + 1) != $this->_namespace . '\\') {
             return false;
         }
     }
     $left = null === $this->_namespace ? $class : \substr($class, \strlen($this->_namespace) + 1);
     if (isset($this->_map[$left])) {
         $fn = (string) ($this->_path === null ? '' : $this->_path . \DIRECTORY_SEPARATOR) . $this->_map[$left];
         if (\is_file($fn)) {
             include $fn;
             autoloadManager::getInstance()->cache($class, $fn);
             unset($this->_map[$left]);
             return true;
         } else {
             require $fn;
             \clearstatcache(true);
             throw new \Exception('File not found "' . $fn . '". Class: "' . $class . '".');
         }
     }
     return false;
 }
예제 #4
0
 protected function __construct()
 {
     autoloadManager::getInstance()->registerNamespaceLoader(array($this, 'autoload'));
 }