8000 [SecurityBundle] Use RequestStack instead of full Container in LogoutUrlHelper by stloyd · Pull Request #10250 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[SecurityBundle] Use RequestStack instead of full Container in LogoutUrlHelper #10250

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

Closed
wants to merge 1 commit into from
Closed
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
[Securi 8000 tyBundle] Don't use deprecated code in LogoutUrlHelper
  • Loading branch information
stloyd committed Feb 12, 2014
commit c98cf3c7f1225cc822b1fc07b9b5d064c12e7e64
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<services>
<service id="templating.helper.logout_url" class="%templating.helper.logout_url.class%">
<tag name="templating.helper" alias="logout_url" />
<argument type="service" id="service_container" />
<argument type="service" id="request_stack" />
<argument type="service" id="router" />
</service>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Symfony\Bundle\SecurityBundle\Templating\Helper;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Templating\Helper\Helper;
Expand All @@ -25,19 +25,19 @@
*/
class LogoutUrlHelper extends Helper
{
private $container;
private $requestStack;
private $listeners = array();
private $router;

/**
* Constructor.
*
* @param ContainerInterface $container A ContainerInterface instance
* @param UrlGeneratorInterface $router A Router instance
* @param RequestStack $requestStack A RequestStack instance
* @param UrlGeneratorInterface $router A Router instance
*/
public function __construct(ContainerInterface $container, UrlGeneratorInterface $router)
public function __construct(RequestStack $requestStack, UrlGeneratorInterface $router)
{
$this->container = $container;
$this->requestStack = $requestStack;
$this->router = $router;
}

Expand All @@ -49,6 +49,8 @@ public function __construct(ContainerInterface $container, UrlGeneratorInterface
* @param string $csrfTokenId The ID of the CSRF token
* @param string $csrfParameter The CSRF token parameter name
* @param CsrfTokenManagerInterface $csrfTokenManager A CsrfTokenManagerInterface instance
*
* @throws \InvalidArgumentException
*/
public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager = null)
{
Expand Down Expand Up @@ -106,7 +108,7 @@ private function generateLogoutUrl($key, $referenceType)
$parameters = null !== $csrfTokenManager ? array($csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)) : array();

if ('/' === $logoutPath[0]) {
$request = $this->container->get('request');
$request = $this->requestStack->getCurrentRequest();

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

Expand Down
0