vendor/symfony/config/Loader/Loader.php line 55

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config\Loader;
  11. use Symfony\Component\Config\Exception\LoaderLoadException;
  12. /**
  13.  * Loader is the abstract class used by all built-in loaders.
  14.  *
  15.  * @author Fabien Potencier <fabien@symfony.com>
  16.  */
  17. abstract class Loader implements LoaderInterface
  18. {
  19.     protected $resolver;
  20.     protected $env;
  21.     public function __construct(string $env null)
  22.     {
  23.         $this->env $env;
  24.     }
  25.     /**
  26.      * {@inheritdoc}
  27.      */
  28.     public function getResolver()
  29.     {
  30.         return $this->resolver;
  31.     }
  32.     /**
  33.      * {@inheritdoc}
  34.      */
  35.     public function setResolver(LoaderResolverInterface $resolver)
  36.     {
  37.         $this->resolver $resolver;
  38.     }
  39.     /**
  40.      * Imports a resource.
  41.      *
  42.      * @param mixed       $resource A resource
  43.      * @param string|null $type     The resource type or null if unknown
  44.      *
  45.      * @return mixed
  46.      */
  47.     public function import($resourcestring $type null)
  48.     {
  49.         return $this->resolve($resource$type)->load($resource$type);
  50.     }
  51.     /**
  52.      * Finds a loader able to load an imported resource.
  53.      *
  54.      * @param mixed       $resource A resource
  55.      * @param string|null $type     The resource type or null if unknown
  56.      *
  57.      * @return LoaderInterface
  58.      *
  59.      * @throws LoaderLoadException If no loader is found
  60.      */
  61.     public function resolve($resourcestring $type null)
  62.     {
  63.         if ($this->supports($resource$type)) {
  64.             return $this;
  65.         }
  66.         $loader null === $this->resolver false $this->resolver->resolve($resource$type);
  67.         if (false === $loader) {
  68.             throw new LoaderLoadException($resourcenull0null$type);
  69.         }
  70.         return $loader;
  71.     }
  72. }