Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
SecurityExtension.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Bridge\Twig\Extension;
13
14 use Symfony\Component\Security\Acl\Voter\FieldVote;
15 use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
16 use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
17
18 /**
19 * SecurityExtension exposes security context features.
20 *
21 * @author Fabien Potencier <fabien@symfony.com>
22 */
23 class SecurityExtension extends \Twig_Extension
24 {
25 private $securityChecker;
26
27 public function __construct(AuthorizationCheckerInterface $securityChecker = null)
28 {
29 $this->securityChecker = $securityChecker;
30 }
31
32 public function isGranted($role, $object = null, $field = null)
33 {
34 if (null === $this->securityChecker) {
35 return false;
36 }
37
38 if (null !== $field) {
39 $object = new FieldVote($object, $field);
40 }
41
42 try {
43 return $this->securityChecker->isGranted($role, $object);
44 } catch (AuthenticationCredentialsNotFoundException $e) {
45 return false;
46 }
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function getFunctions()
53 {
54 return array(
55 new \Twig_SimpleFunction('is_granted', array($this, 'isGranted')),
56 );
57 }
58
59 /**
60 * {@inheritdoc}
61 */
62 public function getName()
63 {
64 return 'security';
65 }
66 }
67