@@ 11-83 (lines=73) @@ | ||
8 | use Knp\Rad\AutoRegistration\Reflection\ClassAnalyzer; |
|
9 | use Symfony\Component\DependencyInjection\Definition; |
|
10 | ||
11 | class SecurityVoterBuilder implements DefinitionBuilder |
|
12 | { |
|
13 | /** |
|
14 | * @var KernelWrapper |
|
15 | */ |
|
16 | private $kernel; |
|
17 | ||
18 | /** |
|
19 | * @var BundleFinder |
|
20 | */ |
|
21 | private $finder; |
|
22 | ||
23 | /** |
|
24 | * @var ClassAnalyzer |
|
25 | */ |
|
26 | private $analyzer; |
|
27 | ||
28 | /** |
|
29 | * @param KernelWrapper $kernel |
|
30 | * @param BundleFinder $finder |
|
31 | * @param ClassAnalyzer $analyzer |
|
32 | */ |
|
33 | public function __construct(KernelWrapper $kernel, BundleFinder $finder, ClassAnalyzer $analyzer) |
|
34 | { |
|
35 | $this->kernel = $kernel; |
|
36 | $this->finder = $finder; |
|
37 | $this->analyzer = $analyzer; |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * {@inheritdoc} |
|
42 | */ |
|
43 | public function buildDefinitions() |
|
44 | { |
|
45 | $definitions = []; |
|
46 | ||
47 | $voters = $this->finder->findClasses( |
|
48 | $this->kernel->getBundles(), |
|
49 | 'Security', |
|
50 | 'Symfony\Component\Security\Core\Authorization\Voter\VoterInterface' |
|
51 | ); |
|
52 | ||
53 | foreach ($voters as $voter) { |
|
54 | if (true === $this->analyzer->needConstruction($voter)) { |
|
55 | continue; |
|
56 | } |
|
57 | ||
58 | $definitions[$voter] = (new Definition()) |
|
59 | ->setClass($voter) |
|
60 | ->setPublic(false) |
|
61 | ->addTag('security.voter') |
|
62 | ; |
|
63 | } |
|
64 | ||
65 | return $definitions; |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * {@inheritdoc} |
|
70 | */ |
|
71 | public function getName() |
|
72 | { |
|
73 | return 'security_voter'; |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * {@inheritdoc} |
|
78 | */ |
|
79 | public function isActive() |
|
80 | { |
|
81 | return true; |
|
82 | } |
|
83 | } |
|
84 |
@@ 11-83 (lines=73) @@ | ||
8 | use Knp\Rad\AutoRegistration\Reflection\ClassAnalyzer; |
|
9 | use Symfony\Component\DependencyInjection\Definition; |
|
10 | ||
11 | class TwigExtensionBuilder implements DefinitionBuilder |
|
12 | { |
|
13 | /** |
|
14 | * @var KernelWrapper |
|
15 | */ |
|
16 | private $kernel; |
|
17 | ||
18 | /** |
|
19 | * @var BundleFinder |
|
20 | */ |
|
21 | private $finder; |
|
22 | ||
23 | /** |
|
24 | * @var ClassAnalyzer |
|
25 | */ |
|
26 | private $analyzer; |
|
27 | ||
28 | /** |
|
29 | * @param KernelWrapper $kernel |
|
30 | * @param BundleFinder $finder |
|
31 | * @param ClassAnalyzer $analyzer |
|
32 | */ |
|
33 | public function __construct(KernelWrapper $kernel, BundleFinder $finder, ClassAnalyzer $analyzer) |
|
34 | { |
|
35 | $this->kernel = $kernel; |
|
36 | $this->finder = $finder; |
|
37 | $this->analyzer = $analyzer; |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * {@inheritdoc} |
|
42 | */ |
|
43 | public function buildDefinitions() |
|
44 | { |
|
45 | $definitions = []; |
|
46 | ||
47 | $twigExtensions = $this->finder->findClasses( |
|
48 | $this->kernel->getBundles(), |
|
49 | ['Twig', 'Templating'], |
|
50 | 'Twig_Extension' |
|
51 | ); |
|
52 | ||
53 | foreach ($twigExtensions as $twigExtension) { |
|
54 | if (true === $this->analyzer->needConstruction($twigExtension)) { |
|
55 | continue; |
|
56 | } |
|
57 | ||
58 | $definitions[$twigExtension] = (new Definition()) |
|
59 | ->setClass($twigExtension) |
|
60 | ->setPublic(false) |
|
61 | ->addTag('twig.extension') |
|
62 | ; |
|
63 | } |
|
64 | ||
65 | return $definitions; |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * {@inheritdoc} |
|
70 | */ |
|
71 | public function getName() |
|
72 | { |
|
73 | return 'twig_extension'; |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * {@inheritdoc} |
|
78 | */ |
|
79 | public function isActive() |
|
80 | { |
|
81 | return true; |
|
82 | } |
|
83 | } |
|
84 |