ImportConfigurator.php 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\Routing\Loader\Configurator;
  11. use Symfony\Component\Routing\RouteCollection;
  12. /**
  13. * @author Nicolas Grekas <p@tchwork.com>
  14. */
  15. class ImportConfigurator
  16. {
  17. use Traits\RouteTrait;
  18. private $parent;
  19. public function __construct(RouteCollection $parent, RouteCollection $route)
  20. {
  21. $this->parent = $parent;
  22. $this->route = $route;
  23. }
  24. public function __destruct()
  25. {
  26. $this->parent->addCollection($this->route);
  27. }
  28. /**
  29. * Sets the prefix to add to the path of all child routes.
  30. *
  31. * @param string $prefix
  32. *
  33. * @return $this
  34. */
  35. final public function prefix($prefix)
  36. {
  37. $this->route->addPrefix($prefix);
  38. return $this;
  39. }
  40. }