prefix = $prefix; foreach ($this->cacheAdapters as $className) { $file = sprintf("%s/%sAutoloader.php", __DIR__, $className); if ( ! file_exists($file)) { continue; } require_once $file; $className = sprintf("\Alchemy\Phrasea\Loader\%sAutoloader", $className); if ( ! class_exists($className)) { continue; } $method = new $className(); if ($namespace) { $method->setNamespace($namespace); } if ($method instanceof LoaderStrategy && $method->isAvailable()) { $this->cacheAdapter = $method; break; } } if (null === $this->cacheAdapter) { throw new \Exception('No Cache available'); } } /** * {@inheritdoc} */ public function findFile($class) { $file = $this->cacheAdapter->fetch($this->prefix . $class); if (false === $file) { $this->cacheAdapter->save($this->prefix . $class, $file = parent::findFile($class)); } return $file; } /** * {@inheritdoc} */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); } /** * Get the current cache Adapter * @return LoaderStrategy */ public function getAdapter() { return $this->cacheAdapter; } /** * Get the identifier cache key prefix * @return string */ public function getPrefix() { return $this->prefix; } }