[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/routing/Loader/Configurator/ -> CollectionConfigurator.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\Route;
  15  use Symfony\Component\Routing\RouteCollection;
  16  
  17  /**
  18   * @author Nicolas Grekas <p@tchwork.com>
  19   */
  20  class CollectionConfigurator
  21  {
  22      use Traits\AddTrait;
  23      use Traits\RouteTrait;
  24  
  25      private $parent;
  26      private $parentConfigurator;
  27  
  28      public function __construct(RouteCollection $parent, $name, self $parentConfigurator = null)
  29      {
  30          $this->parent = $parent;
  31          $this->name = $name;
  32          $this->collection = new RouteCollection();
  33          $this->route = new Route('');
  34          $this->parentConfigurator = $parentConfigurator; // for GC control
  35      }
  36  
  37      public function __destruct()
  38      {
  39          $this->collection->addPrefix(rtrim($this->route->getPath(), '/'));
  40          $this->parent->addCollection($this->collection);
  41      }
  42  
  43      /**
  44       * Adds a route.
  45       *
  46       * @param string $name
  47       * @param string $path
  48       *
  49       * @return RouteConfigurator
  50       */
  51      final public function add($name, $path)
  52      {
  53          $this->collection->add($this->name.$name, $route = clone $this->route);
  54  
  55          return new RouteConfigurator($this->collection, $route->setPath($path), $this->name, $this);
  56      }
  57  
  58      /**
  59       * Creates a sub-collection.
  60       *
  61       * @return self
  62       */
  63      final public function collection($name = '')
  64      {
  65          return new self($this->collection, $this->name.$name, $this);
  66      }
  67  
  68      /**
  69       * Sets the prefix to add to the path of all child routes.
  70       *
  71       * @param string $prefix
  72       *
  73       * @return $this
  74       */
  75      final public function prefix($prefix)
  76      {
  77          $this->route->setPath($prefix);
  78  
  79          return $this;
  80      }
  81  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1