Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\ClassLoader; Chris@0: Chris@14: @trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED); Chris@14: Chris@0: /** Chris@0: * A class loader that uses a mapping file to look up paths. Chris@0: * Chris@0: * @author Fabien Potencier Chris@14: * Chris@14: * @deprecated since version 3.3, to be removed in 4.0. Chris@0: */ Chris@0: class MapClassLoader Chris@0: { Chris@17: private $map = []; Chris@0: Chris@0: /** Chris@0: * @param array $map A map where keys are classes and values the absolute file path Chris@0: */ Chris@0: public function __construct(array $map) Chris@0: { Chris@0: $this->map = $map; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Registers this instance as an autoloader. Chris@0: * Chris@0: * @param bool $prepend Whether to prepend the autoloader or not Chris@0: */ Chris@0: public function register($prepend = false) Chris@0: { Chris@17: spl_autoload_register([$this, 'loadClass'], true, $prepend); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Loads the given class or interface. Chris@0: * Chris@0: * @param string $class The name of the class Chris@0: */ Chris@0: public function loadClass($class) Chris@0: { Chris@0: if (isset($this->map[$class])) { Chris@0: require $this->map[$class]; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Finds the path to the file where the class is defined. Chris@0: * Chris@0: * @param string $class The name of the class Chris@0: * Chris@0: * @return string|null The path, if found Chris@0: */ Chris@0: public function findFile($class) Chris@0: { Chris@0: if (isset($this->map[$class])) { Chris@0: return $this->map[$class]; Chris@0: } Chris@0: } Chris@0: }