10000 removed deprecated notices when using the security service · symfony/symfony@dddc7bc · GitHub
[go: up one dir, main page]

Skip to content

Commit dddc7bc

Browse files
committed
removed deprecated notices when using the security service
1 parent 1067cc5 commit dddc7bc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Symfony/Bridge/Twig/AppVariable.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1818
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1919
use Symfony\Component\Security\Core\SecurityContextInterface;
20+
use Symfony\Component\DependencyInjection\ContainerInterface;
2021

2122
/**
2223
* Exposes some Symfony parameters and services as an "app" global variable.
@@ -25,7 +26,7 @@
2526
*/
2627
class AppVariable
2728
{
28-
private $security;
29+
private $container;
2930
private $tokenStorage;
3031
private $requestStack;
3132
private $environment;
@@ -34,9 +35,9 @@ class AppVariable
3435
/**
3536
* @deprecated since version 2.7, to be removed in 3.0.
3637
*/
37-
public function setSecurity(SecurityContextInterface $security)
38+
public function setContainer(ContainerInterface $container)
3839
{
39-
$this->security = $security;
40+
$this->container = $container;
4041
}
4142

4243
public function setTokenStorage(TokenStorageInterface $tokenStorage)
@@ -70,11 +71,11 @@ public function getSecurity()
7071
{
7172
trigger_error('The "app.security" variable is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
7273

73-
if (null === $this->security) {
74+
if (null === $this->container) {
7475
throw new \RuntimeException('The "app.security" variable is not available.');
7576
}
7677

77-
return $this->security;
78+
return $this->container->get('security');
7879
}
7980

8081
/**

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<service id="twig.app_variable" class="Symfony\Bridge\Twig\AppVariable" public="false">
4242
<call method="setEnvironment"><argument>%kernel.environment%</argument></call>
4343
<call method="setDebug"><argument>%kernel.debug%</argument></call>
44-
<call method="setSecurity"><argument type="service" id="security.context" on-invalid="ignore" /></call>
44+
<call method="setContainer"><argument type="service" id="service_container" /></call>
4545
<call method="setTokenStorage"><argument type="service" id="security.token_storage" on-invalid="ignore" /></call>
4646
<call method="setRequestStack"><argument type="service" id="request_stack" on-invalid="ignore" /></call>
4747
</service>

0 commit comments

Comments
 (0)
0