Skip to content

Commit

Permalink
[TwigBundle] fixed ifrole tag when security context is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 26, 2010
1 parent 1e983a6 commit 07eceb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Symfony/Bundle/TwigBundle/Extension/SecurityExtension.php
Expand Up @@ -27,9 +27,13 @@ public function __construct(SecurityContext $context = null)
$this->context = $context;
}

public function getContext()
public function vote($role, $object = null)
{
return $this->context;
if (null === $this->context) {
return false;
}

return $this->context->vote($role, $object);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Node/IfRoleNode.php
Expand Up @@ -30,7 +30,7 @@ public function compile($compiler)
{
$compiler
->addDebugInfo($this)
->write('if ($this->env->getExtension(\'security\')->getContext()->vote(')
->write('if ($this->env->getExtension(\'security\')->vote(')
->subcompile($this->getNode('role'))
;

Expand Down

0 comments on commit 07eceb7

Please sign in to comment.