1 | <?php |
||
24 | class NotificationsSubjectsPass implements CompilerPassInterface |
||
25 | { |
||
26 | const SUBJECTS_ID = 'incident.siren.notification.subjects.%s.%s'; |
||
27 | const SCHEDULE_ID = 'incident.siren.notification.schedule.%s.%s'; |
||
28 | const INCIDENT_SCHEDULE_PROTOTYPE = 'incident.schedule_prototype'; |
||
29 | const INCIDENT_SUBJECT_PROTOTYPE = 'incident.subject_prototype'; |
||
30 | const INCIDENT_NOTIFICATIONS_SUBJECTS = 'incident.notifications.subjects'; |
||
31 | const INCIDENT_SIREN_NOTIFICATION_SUBJECTS = 'incident.siren.notification.subjects'; |
||
32 | |||
33 | /** |
||
34 | * @var ContainerBuilder |
||
35 | */ |
||
36 | private $container; |
||
37 | |||
38 | /** |
||
39 | * @var SubjectsConfigProvider |
||
40 | */ |
||
41 | private $subjectsProvider; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function process(ContainerBuilder $container) |
||
66 | |||
67 | /** |
||
68 | * @param $taggedServices |
||
69 | */ |
||
70 | protected function processNotificationsTypes($taggedServices) |
||
82 | |||
83 | /** |
||
84 | * @param array $subjects |
||
85 | * @param string $typeName |
||
86 | * @param string $notSubjectsId |
||
87 | */ |
||
88 | protected function processSubjects($subjects, $typeName, $notSubjectsId) |
||
89 | { |
||
90 | foreach ($subjects as $subjectsId => $subjectsItem) { |
||
91 | $subjectDef = $this->createSubjectDef($typeName, $subjectsItem, $subjectsId); |
||
92 | $subjectId = sprintf(self::SUBJECTS_ID, $typeName, $subjectsId); |
||
93 | $this->getContainer()->setDefinition($subjectId, $subjectDef); |
||
94 | $notSubjectsDef = $this->getContainer()->getDefinition($notSubjectsId); |
||
95 | |||
96 | $notSubjectsDef->addMethodCall( |
||
97 | 'add', |
||
98 | [new Reference($subjectId)] |
||
99 | ); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @param string $schedule |
||
105 | * |
||
106 | * @return DefinitionDecorator |
||
107 | */ |
||
108 | protected function createScheduleDef($schedule) |
||
115 | |||
116 | /** |
||
117 | * @param string $typeName |
||
118 | * @param array $subjectsItem |
||
119 | * @param string $subjectsId |
||
120 | * |
||
121 | * @return DefinitionDecorator |
||
122 | */ |
||
123 | protected function createSubjectDef($typeName, $subjectsItem, $subjectsId) |
||
139 | |||
140 | /** |
||
141 | * @return ContainerBuilder |
||
142 | */ |
||
143 | protected function getContainer() |
||
147 | |||
148 | /** |
||
149 | * @return mixed |
||
150 | */ |
||
151 | protected function getSubjectsProvider() |
||
155 | |||
156 | /** |
||
157 | * @param ContainerBuilder $container |
||
158 | */ |
||
159 | private function setContainer(ContainerBuilder $container) |
||
163 | |||
164 | /** |
||
165 | * @param mixed $subjectsProvider |
||
166 | */ |
||
167 | private function setSubjectsProvider($subjectsProvider) |
||
171 | } |
||
172 |