From dde442f1c17f283f36d5494ca03cfd134c1ffa15 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 20 Apr 2020 12:17:32 +0200 Subject: [PATCH] [Routing][PrefixTrait] Add the _locale requirement --- .../Component/Routing/Loader/Configurator/Traits/PrefixTrait.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php b/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php index 5c109f942f11f..27053bcaf546b 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php @@ -33,6 +33,7 @@ final protected function addPrefix(RouteCollection $routes, $prefix, bool $trail foreach ($prefix as $locale => $localePrefix) { $localizedRoute = clone $route; $localizedRoute->setDefault('_locale', $locale); + $localizedRoute->setRequirement('_locale', preg_quote($locale)); $localizedRoute->setDefault('_canonical_route', $name); $localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath())); $routes->add($name.'.'.$locale, $localizedRoute);