Skip to content

Commit e134083

Browse files
committed
minor #20417 [Routing] Rename variable to stay consistent (OskarStark)
This PR was merged into the 5.4 branch. Discussion ---------- [Routing] Rename variable to stay consistent Here we are using `$urlGenerator` * https://symfony.com/doc/6.4/routing.html#generating-urls-in-commands * https://symfony.com/doc/6.4/security.html#customizing-logout * https://symfony.com/doc/6.4/security.html#customizing-logout cc `@mvhirsch` Commits ------- 0b5820f Rename variable to stay consistent
2 parents efb4ecb + 0b5820f commit e134083

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

routing.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,32 +2671,32 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
26712671

26722672
class SomeService
26732673
{
2674-
private $router;
2674+
private $urlGenerator;
26752675

2676-
public function __construct(UrlGeneratorInterface $router)
2676+
public function __construct(UrlGeneratorInterface $urlGenerator)
26772677
{
2678-
$this->router = $router;
2678+
$this->urlGenerator = $urlGenerator;
26792679
}
26802680

26812681
public function someMethod()
26822682
{
26832683
// ...
26842684

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

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

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

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

0 commit comments

Comments
 (0)