From 09ed9b5495ba4d159e8f14ec46972f05561a3325 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Jan 2015 23:54:06 +0100 Subject: [PATCH] removed deprecated notices when using the security service --- src/Symfony/Bridge/Twig/AppVariable.php | 12 ++++++------ .../Bundle/TwigBundle/Resources/config/twig.xml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 6851214b316f..3c47570f7d40 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\SecurityContextInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Exposes some Symfony parameters and services as an "app" global variable. @@ -25,7 +25,7 @@ */ class AppVariable { - private $security; + private $container; private $tokenStorage; private $requestStack; private $environment; @@ -34,9 +34,9 @@ class AppVariable /** * @deprecated since version 2.7, to be removed in 3.0. */ - public function setSecurity(SecurityContextInterface $security) + public function setContainer(ContainerInterface $container) { - $this->security = $security; + $this->container = $container; } public function setTokenStorage(TokenStorageInterface $tokenStorage) @@ -70,11 +70,11 @@ public function getSecurity() { trigger_error('The "app.security" variable is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED); - if (null === $this->security) { + if (null === $this->container) { throw new \RuntimeException('The "app.security" variable is not available.'); } - return $this->security; + return $this->container->get('security'); } /** diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 2d46cdb5aa59..2a11e3750d9f 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -41,7 +41,7 @@ %kernel.environment% %kernel.debug% - +