Skip to content

Commit

Permalink
Rename variable to stay consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Nov 27, 2024
1 parent efb4ecb commit 0b5820f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2671,32 +2671,32 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class

class SomeService
{
private $router;
private $urlGenerator;

public function __construct(UrlGeneratorInterface $router)
public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->router = $router;
$this->urlGenerator = $urlGenerator;
}

public function someMethod()
{
// ...

// 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 0b5820f

Please sign in to comment.