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

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(): LoaderResolverInterface
  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.      * @return mixed
  43.      */
  44.     public function import(mixed $resourcestring $type null)
  45.     {
  46.         return $this->resolve($resource$type)->load($resource$type);
  47.     }
  48.     /**
  49.      * Finds a loader able to load an imported resource.
  50.      *
  51.      * @throws LoaderLoadException If no loader is found
  52.      */
  53.     public function resolve(mixed $resourcestring $type null): LoaderInterface
  54.     {
  55.         if ($this->supports($resource$type)) {
  56.             return $this;
  57.         }
  58.         $loader null === $this->resolver false $this->resolver->resolve($resource$type);
  59.         if (false === $loader) {
  60.             throw new LoaderLoadException($resourcenull0null$type);
  61.         }
  62.         return $loader;
  63.     }
  64. }