[TwigBundle] fixed cache problem for some global variables
This commit is contained in:
parent
6dd1d6172f
commit
b056a6c3c1
@ -22,11 +22,6 @@ class GlobalVariables
|
|||||||
{
|
{
|
||||||
protected $container;
|
protected $container;
|
||||||
|
|
||||||
// act as a cache to avoid calling the getters more than once
|
|
||||||
// request related variables cannot be cached as we can have sub-requests
|
|
||||||
public $security;
|
|
||||||
public $user;
|
|
||||||
|
|
||||||
public function __construct(ContainerInterface $container)
|
public function __construct(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
@ -35,19 +30,16 @@ class GlobalVariables
|
|||||||
public function getSecurity()
|
public function getSecurity()
|
||||||
{
|
{
|
||||||
if ($this->container->has('security.context')) {
|
if ($this->container->has('security.context')) {
|
||||||
$this->security = $this->container->get('security.context');
|
return $this->security = $this->container->get('security.context');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->security;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser()
|
public function getUser()
|
||||||
{
|
{
|
||||||
if ($security = $this->getSecurity() && $user = $security->getUser()) {
|
$security = $this->getSecurity();
|
||||||
$this->user = $user;
|
if ($security && $user = $security->getUser()) {
|
||||||
|
return $this->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest()
|
public function getRequest()
|
||||||
|
Reference in New Issue
Block a user