From 433d76bfe1165eb644da2c0bc28759c3bce445c4 Mon Sep 17 00:00:00 2001 From: roromix <16560617+roromix@users.noreply.github.com> Date: Tue, 30 Mar 2021 15:59:08 +0200 Subject: [PATCH] LoginLink create get Request Locale --- .../Component/Security/Http/LoginLink/LoginLinkHandler.php | 6 +++++- .../Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php b/src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php index bfa67d6b6e..ec4cf65f0a 100644 --- a/src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php +++ b/src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php @@ -64,7 +64,11 @@ final class LoginLinkHandler implements LoginLinkHandlerInterface 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 { diff --git a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php index 74050396ac..1392a5214f 100644 --- a/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php @@ -69,7 +69,11 @@ class LoginLinkHandlerTest extends TestCase 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);