8000 LoginLink create get Request Locale by roromix · Pull Request #40641 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

LoginLink create get Request Locale #40641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
LoginLink create get Request Locale
  • Loading branch information
roromix authored and fabpot committed Apr 2, 2021
commit 433d76bfe1165eb644da2c0bc28759c3bce445c4
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function createLoginLink(UserInterface $user, Request $request = null): L

if ($request) {
$currentRequestContext = $this->urlGenerator->getContext();
$this->urlGenerator->setContext((new RequestContext())->fromRequest($request));
$this->urlGenerator->setContext(
(new RequestContext())
->fromRequest($request)
->setParameter('_locale', $request->getLocale())
);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public function testCreateLoginLink($user, array $extraProperties, Request $requ
if ($request) {
$this->router->expects($this->once())
->method('getContext')
->willReturn(new RequestContext());
->willReturn($currentRequestContext = new RequestContext());

$this->router->expects($this->exactly(2))
->method('setContext')
->withConsecutive([$this->equalTo((new RequestContext())->fromRequest($request)->setParameter('_locale', $request->getLocale()))], [$currentRequestContext]);
}

$loginLink = $this->createLinker([], array_keys($extraProperties))->createLoginLink($user, $request);
Expand Down
0