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;
14 use Symfony\Component\Config\Exception\FileLoaderLoadException;
17 * Loader is the abstract class used by all built-in loaders.
19 * @author Fabien Potencier <fabien@symfony.com>
21 abstract class Loader implements LoaderInterface
28 public function getResolver()
30 return $this->resolver;
36 public function setResolver(LoaderResolverInterface $resolver)
38 $this->resolver = $resolver;
44 * @param mixed $resource A resource
45 * @param string|null $type The resource type or null if unknown
49 public function import($resource, $type = null)
51 return $this->resolve($resource, $type)->load($resource, $type);
55 * Finds a loader able to load an imported resource.
57 * @param mixed $resource A resource
58 * @param string|null $type The resource type or null if unknown
60 * @return $this|LoaderInterface
62 * @throws FileLoaderLoadException If no loader is found
64 public function resolve($resource, $type = null)
66 if ($this->supports($resource, $type)) {
70 $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
72 if (false === $loader) {
73 throw new FileLoaderLoadException($resource);