mirror of
https://github.com/symfony/symfony-docs.git
synced 2026-03-24 00:32:14 +01:00
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:
@@ -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'])
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user