8000 [Routing][PrefixTrait] Add the _locale requirement · symfony/symfony@dde442f · GitHub
[go: up one dir, main page]

Skip to content

Commit dde442f

Browse files
committed
[Routing][PrefixTrait] Add the _locale requirement
1 parent e464954 commit dde442f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ final protected function addPrefix(RouteCollection $routes, $prefix, bool $trail
3333
foreach ($prefix as $locale => $localePrefix) {
3434
$localizedRoute = clone $route;
3535
$localizedRoute->setDefault('_locale', $locale);
36+
$localizedRoute->setRequirement('_locale', preg_quote($locale));
3637
$localizedRoute->setDefault('_canonical_route', $name);
3738
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
3839
$routes->add($name.'.'.$locale, $localizedRoute);

0 commit comments

Comments
 (0)
0