RouteConfigurator.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 RouteConfigurator
  16. {
  17. use Traits\AddTrait;
  18. use Traits\HostTrait;
  19. use Traits\RouteTrait;
  20. public function __construct(
  21. RouteCollection $collection,
  22. RouteCollection $route,
  23. string $name = '',
  24. protected ?CollectionConfigurator $parentConfigurator = null, // for GC control
  25. ?array $prefixes = null,
  26. ) {
  27. $this->collection = $collection;
  28. $this->route = $route;
  29. $this->name = $name;
  30. $this->prefixes = $prefixes;
  31. }
  32. /**
  33. * Sets the host to use for all child routes.
  34. *
  35. * @param string|array $host the host, or the localized hosts
  36. *
  37. * @return $this
  38. */
  39. final public function host(string|array $host): static
  40. {
  41. $this->addHost($this->route, $host);
  42. return $this;
  43. }
  44. }