Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved the Security Twig extension to the bridge

  • Loading branch information...
commit 6064282aa061e45c740f8174e198dc8c7710c20e 1 parent ce92f3d
@fabpot fabpot authored
View
2  Resources/config/templating_twig.xml
@@ -6,7 +6,7 @@
<parameters>
<parameter key="twig.extension.logout_url.class">Symfony\Bundle\SecurityBundle\Twig\Extension\LogoutUrlExtension</parameter>
- <parameter key="twig.extension.security.class">Symfony\Bundle\SecurityBundle\Twig\Extension\SecurityExtension</parameter>
+ <parameter key="twig.extension.security.class">Symfony\Bridge\Twig\Extension\SecurityExtension</parameter>
</parameters>
<services>
View
63 Twig/Extension/SecurityExtension.php
@@ -1,63 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\SecurityBundle\Twig\Extension;
-
-use Symfony\Component\Security\Acl\Voter\FieldVote;
-use Symfony\Component\Security\Core\SecurityContextInterface;
-
-/**
- * SecurityExtension exposes security context features.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class SecurityExtension extends \Twig_Extension
-{
- private $context;
-
- public function __construct(SecurityContextInterface $context = null)
- {
- $this->context = $context;
- }
-
- public function isGranted($role, $object = null, $field = null)
- {
- if (null === $this->context) {
- return false;
- }
-
- if (null !== $field) {
- $object = new FieldVote($object, $field);
- }
-
- return $this->context->isGranted($role, $object);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFunctions()
- {
- return array(
- 'is_granted' => new \Twig_Function_Method($this, 'isGranted'),
- );
- }
-
- /**
- * Returns the name of the extension.
- *
- * @return string The extension name
- */
- public function getName()
- {
- return 'security';
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.