Skip to content

Commit

Permalink
[TwigBundle] fixed cache problem for some global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 12, 2011
1 parent 6dd1d61 commit b056a6c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/Symfony/Bundle/TwigBundle/GlobalVariables.php
Expand Up @@ -22,11 +22,6 @@ class GlobalVariables
{
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)
{
$this->container = $container;
Expand All @@ -35,19 +30,16 @@ public function __construct(ContainerInterface $container)
public function getSecurity()
{
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()
{
if ($security = $this->getSecurity() && $user = $security->getUser()) {
$this->user = $user;
$security = $this->getSecurity();
if ($security && $user = $security->getUser()) {
return $this->user = $user;
}

return $this->user;
}

public function getRequest()
Expand Down

0 comments on commit b056a6c

Please sign in to comment.