1 | <?php |
||
17 | class WorkerRunnersPass implements CompilerPassInterface |
||
18 | { |
||
19 | |||
20 | const WORKER_RUNNER_TAG = 'gendoria_command_queue.worker'; |
||
21 | const MANAGER_ID = 'gendoria_command_queue.runner_manager'; |
||
22 | |||
23 | /** |
||
24 | * Process all services tagged as worker runners and add them to runner manager service. |
||
25 | * |
||
26 | * @param ContainerBuilder $container |
||
27 | * @throws InvalidArgumentException Thrown, if service initialization failed. |
||
28 | */ |
||
29 | 5 | public function process(ContainerBuilder $container) |
|
38 | |||
39 | /** |
||
40 | * Parse single tagged service. |
||
41 | * |
||
42 | * @param ContainerBuilder $container |
||
43 | * @param Definition $manager |
||
44 | * @param string $serviceId |
||
45 | * @param array $tags |
||
46 | * @throws InvalidArgumentException Thrown, if service initialization failed. |
||
47 | */ |
||
48 | 4 | private function addManagerCalls(ContainerBuilder $container, Definition $manager, $serviceId, array $tags) |
|
54 | |||
55 | /** |
||
56 | * Parse single tagged service tag. |
||
57 | * |
||
58 | * @param ContainerBuilder $container |
||
59 | * @param Definition $manager |
||
60 | * @param string $serviceId |
||
61 | * @param array $tag |
||
62 | * @throws InvalidArgumentException Thrown, if service initialization failed. |
||
63 | */ |
||
64 | 4 | private function addManagerCall(ContainerBuilder $container, Definition $manager, $serviceId, array $tag) |
|
72 | |||
73 | /** |
||
74 | * Assert correct tag structure. |
||
75 | * |
||
76 | * @param array $tag |
||
77 | * @throws InvalidArgumentException Thrown, if tag does not contain correct fields. |
||
78 | */ |
||
79 | 4 | private function assertCorrectName(array $tag) |
|
85 | |||
86 | /** |
||
87 | * Assert correct options structure. |
||
88 | * |
||
89 | * @param moxed $options |
||
90 | * @throws InvalidArgumentException Thrown, if options are invalid (not an array). |
||
91 | */ |
||
92 | 2 | private function assertCorrectOptions($options) |
|
98 | |||
99 | /** |
||
100 | * Assert valid tagged service. |
||
101 | * |
||
102 | * @param ContainerBuilder $container |
||
103 | * @param string $serviceId |
||
104 | * @throws InvalidArgumentException Thrown, if tagged service does not implement correct interfaces. |
||
105 | */ |
||
106 | 3 | private function assertCorrectService(ContainerBuilder $container, $serviceId) |
|
114 | } |
||
115 |