minor #21745 [Routing] Default path for localized routes (javiereguiluz)

This PR was merged into the 6.4 branch.

Discussion
----------

[Routing] Default path for localized routes

I tried to merge #20218 but it failed, so let's recreate it here.

YAML format is not included because this feature doesn't work (you cannot define an entry without a key or with an empty key).

Commits
-------

cc251044b [Routing] Default path for localized routes
This commit is contained in:
Javier Eguiluz
2026-01-23 12:53:36 +01:00

View File

@@ -2199,6 +2199,9 @@ avoids the need for duplicating routes, which also reduces the potential bugs:
#[Route(path: [
'en' => '/about-us',
'nl' => '/over-ons'
// optionally, you can define a path without a locale. It will be used
// for any locale that does not match the locales above
'/about-us',
], name: 'about_us')]
public function about(): Response
{
@@ -2240,6 +2243,9 @@ avoids the need for duplicating routes, which also reduces the potential bugs:
$routes->add('about_us', [
'en' => '/about-us',
'nl' => '/over-ons',
// optionally, you can define a path without a locale. It will be used
// for any locale that does not match the locales above
'/about-us',
])
->controller([CompanyController::class, 'about'])
;