[ Index ]

PHP Cross Reference of phpBB-3.3.5-deutsch

title

Body

[close]

/vendor/symfony/routing/Loader/Configurator/ -> RoutingConfigurator.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\Routing\Loader\Configurator;
  13  
  14  use Symfony\Component\Routing\Loader\PhpFileLoader;
  15  use Symfony\Component\Routing\RouteCollection;
  16  
  17  /**
  18   * @author Nicolas Grekas <p@tchwork.com>
  19   */
  20  class RoutingConfigurator
  21  {
  22      use Traits\AddTrait;
  23  
  24      private $loader;
  25      private $path;
  26      private $file;
  27  
  28      public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file)
  29      {
  30          $this->collection = $collection;
  31          $this->loader = $loader;
  32          $this->path = $path;
  33          $this->file = $file;
  34      }
  35  
  36      /**
  37       * @return ImportConfigurator
  38       */
  39      final public function import($resource, $type = null, $ignoreErrors = false)
  40      {
  41          $this->loader->setCurrentDir(\dirname($this->path));
  42          $imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file) ?: [];
  43  
  44          if (!\is_array($imported)) {
  45              return new ImportConfigurator($this->collection, $imported);
  46          }
  47  
  48          $mergedCollection = new RouteCollection();
  49          foreach ($imported as $subCollection) {
  50              $mergedCollection->addCollection($subCollection);
  51          }
  52  
  53          return new ImportConfigurator($this->collection, $mergedCollection);
  54      }
  55  
  56      /**
  57       * @return CollectionConfigurator
  58       */
  59      final public function collection($name = '')
  60      {
  61          return new CollectionConfigurator($this->collection, $name);
  62      }
  63  }


Generated: Mon Oct 4 17:42:11 2021 Cross-referenced by PHPXref 0.7.1