Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 use Twig\Extension\AbstractExtension;
18 use Twig\TwigFunction;
19
20 /**
21 * SecurityExtension exposes security context features.
22 *
23 * @author Fabien Potencier <fabien@symfony.com>
24 */
25 class SecurityExtension extends AbstractExtension
26 {
27 private $securityChecker;
28
29 public function __construct(AuthorizationCheckerInterface $securityChecker = null)
30 {
31 $this->securityChecker = $securityChecker;
32 }
33
34 public function isGranted($role, $object = null, $field = null)
35 {
36 if (null === $this->securityChecker) {
37 return false;
38 }
39
40 if (null !== $field) {
41 $object = new FieldVote($object, $field);
42 }
43
44 try {
45 return $this->securityChecker->isGranted($role, $object);
46 } catch (AuthenticationCredentialsNotFoundException $e) {
47 return false;
48 }
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function getFunctions()
55 {
56 return [
57 new TwigFunction('is_granted', [$this, 'isGranted']),
58 ];
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public function getName()
65 {
66 return 'security';
67 }
68 }
69