1 | <?php |
||
16 | class EventCompilerPass implements CompilerPassInterface |
||
17 | { |
||
18 | use FileCacheTrait; |
||
19 | |||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | 1 | public function process(ContainerBuilder $container) |
|
27 | |||
28 | /** |
||
29 | * @return array |
||
30 | * @throws Exception |
||
31 | */ |
||
32 | 1 | private function getEvents() |
|
45 | |||
46 | /** |
||
47 | * @param ReflectionClass $reflection |
||
48 | * @param $events |
||
49 | * @param string $class |
||
50 | * @throws Exception |
||
51 | */ |
||
52 | 1 | private function handleEvent(ReflectionClass $reflection, array &$events, string $class) |
|
53 | { |
||
54 | 1 | foreach (array_values($reflection->getConstants()) as $constant) { |
|
55 | 1 | if (strlen($constant) < 3 || strpos($constant, '.') === false) { |
|
56 | 1 | continue; |
|
57 | } |
||
58 | |||
59 | 1 | if (isset($events[$constant])) { |
|
60 | throw new Exception(sprintf( |
||
61 | 'Event "%s" was already defined in "%s". (%s)', |
||
62 | $constant, |
||
63 | $events[$constant], |
||
64 | $class |
||
65 | )); |
||
66 | } |
||
67 | |||
68 | 1 | $parameters = $this->getParameters($reflection); |
|
69 | |||
70 | 1 | $events[$constant] = [ |
|
71 | 1 | 'class' => $class, |
|
72 | 1 | 'parameters' => $parameters |
|
73 | ]; |
||
74 | } |
||
75 | 1 | } |
|
76 | |||
77 | /** |
||
78 | * @param ReflectionClass $reflection |
||
79 | * @return array |
||
80 | */ |
||
81 | 1 | private function getParameters(ReflectionClass $reflection) |
|
90 | } |
||
91 |