4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\ClassLoader;
15 * A class loader that uses a mapping file to look up paths.
17 * @author Fabien Potencier <fabien@symfony.com>
21 private $map = array();
26 * @param array $map A map where keys are classes and values the absolute file path
28 public function __construct(array $map)
34 * Registers this instance as an autoloader.
36 * @param bool $prepend Whether to prepend the autoloader or not
38 public function register($prepend = false)
40 spl_autoload_register(array($this, 'loadClass'), true, $prepend);
44 * Loads the given class or interface.
46 * @param string $class The name of the class
48 public function loadClass($class)
50 if (isset($this->map[$class])) {
51 require $this->map[$class];
56 * Finds the path to the file where the class is defined.
58 * @param string $class The name of the class
60 * @return string|null The path, if found
62 public function findFile($class)
64 if (isset($this->map[$class])) {
65 return $this->map[$class];