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

  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.     public function getResolver(): LoaderResolverInterface
  26.     {
  27.         return $this->resolver;
  28.     }
  29.     public function setResolver(LoaderResolverInterface $resolver)
  30.     {
  31.         $this->resolver $resolver;
  32.     }
  33.     /**
  34.      * Imports a resource.
  35.      *
  36.      * @return mixed
  37.      */
  38.     public function import(mixed $resourcestring $type null)
  39.     {
  40.         return $this->resolve($resource$type)->load($resource$type);
  41.     }
  42.     /**
  43.      * Finds a loader able to load an imported resource.
  44.      *
  45.      * @throws LoaderLoadException If no loader is found
  46.      */
  47.     public function resolve(mixed $resourcestring $type null): LoaderInterface
  48.     {
  49.         if ($this->supports($resource$type)) {
  50.             return $this;
  51.         }
  52.         $loader null === $this->resolver false $this->resolver->resolve($resource$type);
  53.         if (false === $loader) {
  54.             throw new LoaderLoadException($resourcenull0null$type);
  55.         }
  56.         return $loader;
  57.     }
  58. }