Skip to content

Commit

Permalink
removed deprecated notices when using the security service
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 20, 2015
1 parent 1067cc5 commit 09ed9b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Symfony/Bridge/Twig/AppVariable.php
Expand Up @@ -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.
Expand All @@ -25,7 +25,7 @@
*/
class AppVariable
{
private $security;
private $container;
private $tokenStorage;
private $requestStack;
private $environment;
Expand All @@ -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)
Expand Down Expand Up @@ -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');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Expand Up @@ -41,7 +41,7 @@
<service id="twig.app_variable" class="Symfony\Bridge\Twig\AppVariable" public="false">
<call method="setEnvironment"><argument>%kernel.environment%</argument></call>
<call method="setDebug"><argument>%kernel.debug%</argument></call>
<call method="setSecurity"><argument type="service" id="security.context" on-invalid="ignore" /></call>
<call method="setContainer"><argument type="service" id="service_container" /></call>
<call method="setTokenStorage"><argument type="service" id="security.token_storage" on-invalid="ignore" /></call>
<call method="setRequestStack"><argument type="service" id="request_stack" on-invalid="ignore" /></call>
</service>
Expand Down

0 comments on commit 09ed9b5

Please sign in to comment.