paths['config'] = __DIR__ . '/../../../../config/classes/'; $this->paths['library'] = __DIR__ . '/../../../classes/'; $getComposerClassMap = function() { return require realpath(__DIR__ . '/../../../../vendor/composer/autoload_classmap.php'); }; $this->classmap = $getComposerClassMap(); } /** * {@inheritdoc} */ public function findFile($class) { if ( ! $file = $this->checkFile($class)) { $file = parent::findFile($class); } return $file; } /** * Add a path to look for autoloading phraseanet classes * @param string $name * @param string $path */ public function addPath($name, $path) { $this->paths[$name] = \p4string::addEndSlash($path); } /** * Check whether a class with $class name exists * foreach declared paths * @param string $class * @return mixed string|null */ private function checkFile($classname) { if (isset($this->classmap[$classname])) { return $this->classmap[$classname]; } $normalized_classname = str_replace('_', '/', $classname); foreach ($this->paths as $path) { $file = $path . $normalized_classname . '.class.php'; if (file_exists($file)) { return $file; } } } /** * Get Paths where classes are checked for autoloading * @return Array */ public function getPaths() { return $this->paths; } }