Skip to content

Commit 777a11b

Browse files
committed
removed as many usage of the request service as possible without breaking BC
1 parent e176774 commit 777a11b

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Templating/Helper/LogoutUrlHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private function generateLogoutUrl($key, $referenceType)
106106
$parameters = null !== $csrfTokenManager ? array($csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)) : array();
107107

108108
if ('/' === $logoutPath[0]) {
109-
$request = $this->container->get('request');
109+
$request = $this->container->get('request_stack')->getCurrentRequest();
110110

111111
$url = UrlGeneratorInterface::ABSOLUTE_URL === $referenceType ? $request->getUriForPath($logoutPath) : $request->getBasePath().$logoutPath;
112112

Tests/Functional/Bundle/FormLoginBundle/Controller/LocalizedController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;
1313

1414
use Symfony\Component\Security\Core\SecurityContext;
15+
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\DependencyInjection\ContainerAware;
1718

1819
class LocalizedController extends ContainerAware
1920
{
20-
public function loginAction()
21+
public function loginAction(Request $request)
2122
{
2223
// get the login error if there is one
23-
if ($this->container->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
24-
$error = $this->container->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
24+
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
25+
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
2526
} else {
26-
$error = $this->container->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
27+
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
2728
}
2829

2930
return $this->container->get('templating')->renderResponse('FormLoginBundle:Localized:login.html.twig', array(
3031
// last username entered by the user
31-
'last_username' => $this->container->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
32+
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
3233
'error' => $error,
3334
));
3435
}

Tests/Functional/Bundle/FormLoginBundle/Controller/LoginController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;
1313

1414
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
15+
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\Security\Core\SecurityContext;
1718
use Symfony\Component\DependencyInjection\ContainerAware;
1819

1920
class LoginController extends ContainerAware
2021
{
21-
public function loginAction()
22+
public function loginAction(Request $request)
2223
{
2324
// get the login error if there is one
24-
if ($this->container->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
25-
$error = $this->container->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
25+
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
26+
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
2627
} else {
27-
$error = $this->container->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
28+
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
2829
}
2930

3031
return $this->container->get('templating')->renderResponse('FormLoginBundle:Login:login.html.twig', array(
3132
// last username entered by the user
32-
'last_username' => $this->container->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
33+
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
3334
'error' => $error,
3435
));
3536
}

0 commit comments

Comments
 (0)