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();
30 * @param LoaderInterface[] $loaders An array of loaders
32 public function __construct(array $loaders = array())
34 foreach ($loaders as $loader) {
35 $this->addLoader($loader);
42 public function resolve($resource, $type = null)
44 foreach ($this->loaders as $loader) {
45 if ($loader->supports($resource, $type)) {
53 public function addLoader(LoaderInterface $loader)
55 $this->loaders[] = $loader;
56 $loader->setResolver($this);
60 * Returns the registered loaders.
62 * @return LoaderInterface[] An array of LoaderInterface instances
64 public function getLoaders()
66 return $this->loaders;