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\Config\Loader;
15 * LoaderResolver selects a loader for a given resource.
17 * A resource can be anything (e.g. a full path to a config file or a Closure).
18 * Each loader determines whether it can load a resource and how.
20 * @author Fabien Potencier <fabien@symfony.com>
22 class LoaderResolver implements LoaderResolverInterface
25 * @var LoaderInterface[] An array of LoaderInterface objects
27 private $loaders = array();
32 * @param LoaderInterface[] $loaders An array of loaders
34 public function __construct(array $loaders = array())
36 foreach ($loaders as $loader) {
37 $this->addLoader($loader);
44 public function resolve($resource, $type = null)
46 foreach ($this->loaders as $loader) {
47 if ($loader->supports($resource, $type)) {
58 * @param LoaderInterface $loader A LoaderInterface instance
60 public function addLoader(LoaderInterface $loader)
62 $this->loaders[] = $loader;
63 $loader->setResolver($this);
67 * Returns the registered loaders.
69 * @return LoaderInterface[] An array of LoaderInterface instances
71 public function getLoaders()
73 return $this->loaders;