[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/vendor/symfony/config/Symfony/Component/Config/Loader/ -> LoaderResolver.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Config\Loader;
  13  
  14  /**
  15   * LoaderResolver selects a loader for a given resource.
  16   *
  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.
  19   *
  20   * @author Fabien Potencier <fabien@symfony.com>
  21   */
  22  class LoaderResolver implements LoaderResolverInterface
  23  {
  24      /**
  25       * @var LoaderInterface[] An array of LoaderInterface objects
  26       */
  27      private $loaders;
  28  
  29      /**
  30       * Constructor.
  31       *
  32       * @param LoaderInterface[] $loaders An array of loaders
  33       */
  34      public function __construct(array $loaders = array())
  35      {
  36          $this->loaders = array();
  37          foreach ($loaders as $loader) {
  38              $this->addLoader($loader);
  39          }
  40      }
  41  
  42      /**
  43       * {@inheritdoc}
  44       */
  45      public function resolve($resource, $type = null)
  46      {
  47          foreach ($this->loaders as $loader) {
  48              if ($loader->supports($resource, $type)) {
  49                  return $loader;
  50              }
  51          }
  52  
  53          return false;
  54      }
  55  
  56      /**
  57       * Adds a loader.
  58       *
  59       * @param LoaderInterface $loader A LoaderInterface instance
  60       */
  61      public function addLoader(LoaderInterface $loader)
  62      {
  63          $this->loaders[] = $loader;
  64          $loader->setResolver($this);
  65      }
  66  
  67      /**
  68       * Returns the registered loaders.
  69       *
  70       * @return LoaderInterface[] An array of LoaderInterface instances
  71       */
  72      public function getLoaders()
  73      {
  74          return $this->loaders;
  75      }
  76  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1