Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  Rename variable to stay consistent
  • Loading branch information
OskarStark committed Nov 27, 2024
2 parents 4a27315 + e134083 commit f0bcff3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
class SomeService
{
public function __construct(
private UrlGeneratorInterface $router,
private UrlGeneratorInterface $urlGenerator,
) {
}

Expand All @@ -2424,20 +2424,20 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
// ...

// generate a URL with no route arguments
$signUpPage = $this->router->generate('sign_up');
$signUpPage = $this->urlGenerator->generate('sign_up');

// generate a URL with route arguments
$userProfilePage = $this->router->generate('user_profile', [
$userProfilePage = $this->urlGenerator->generate('user_profile', [
'username' => $user->getUserIdentifier(),
]);

// generated URLs are "absolute paths" by default. Pass a third optional
// argument to generate different URLs (e.g. an "absolute URL")
$signUpPage = $this->router->generate('sign_up', [], UrlGeneratorInterface::ABSOLUTE_URL);
$signUpPage = $this->urlGenerator->generate('sign_up', [], UrlGeneratorInterface::ABSOLUTE_URL);

// when a route is localized, Symfony uses by default the current request locale
// pass a different '_locale' value if you want to set the locale explicitly
$signUpPageInDutch = $this->router->generate('sign_up', ['_locale' => 'nl']);
$signUpPageInDutch = $this->urlGenerator->generate('sign_up', ['_locale' => 'nl']);
}
}

Expand Down

0 comments on commit f0bcff3

Please sign in to comment.