@@ -39,402 +39,402 @@ |
||
39 | 39 | |
40 | 40 | class RegistrationContext { |
41 | 41 | |
42 | - /** @var array[] */ |
|
43 | - private $capabilities = []; |
|
44 | - |
|
45 | - /** @var array[] */ |
|
46 | - private $crashReporters = []; |
|
47 | - |
|
48 | - /** @var array[] */ |
|
49 | - private $dashboardPanels = []; |
|
50 | - |
|
51 | - /** @var array[] */ |
|
52 | - private $services = []; |
|
53 | - |
|
54 | - /** @var array[] */ |
|
55 | - private $aliases = []; |
|
56 | - |
|
57 | - /** @var array[] */ |
|
58 | - private $parameters = []; |
|
59 | - |
|
60 | - /** @var array[] */ |
|
61 | - private $eventListeners = []; |
|
62 | - |
|
63 | - /** @var array[] */ |
|
64 | - private $middlewares = []; |
|
65 | - |
|
66 | - /** @var array[] */ |
|
67 | - private $searchProviders = []; |
|
68 | - |
|
69 | - /** @var array[] */ |
|
70 | - private $alternativeLogins = []; |
|
71 | - |
|
72 | - /** @var array[] */ |
|
73 | - private $initialStates = []; |
|
74 | - |
|
75 | - /** @var ILogger */ |
|
76 | - private $logger; |
|
77 | - |
|
78 | - public function __construct(ILogger $logger) { |
|
79 | - $this->logger = $logger; |
|
80 | - } |
|
81 | - |
|
82 | - public function for(string $appId): IRegistrationContext { |
|
83 | - return new class($appId, $this) implements IRegistrationContext { |
|
84 | - /** @var string */ |
|
85 | - private $appId; |
|
86 | - |
|
87 | - /** @var RegistrationContext */ |
|
88 | - private $context; |
|
89 | - |
|
90 | - public function __construct(string $appId, RegistrationContext $context) { |
|
91 | - $this->appId = $appId; |
|
92 | - $this->context = $context; |
|
93 | - } |
|
94 | - |
|
95 | - public function registerCapability(string $capability): void { |
|
96 | - $this->context->registerCapability( |
|
97 | - $this->appId, |
|
98 | - $capability |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - public function registerCrashReporter(string $reporterClass): void { |
|
103 | - $this->context->registerCrashReporter( |
|
104 | - $this->appId, |
|
105 | - $reporterClass |
|
106 | - ); |
|
107 | - } |
|
108 | - |
|
109 | - public function registerDashboardWidget(string $widgetClass): void { |
|
110 | - $this->context->registerDashboardPanel( |
|
111 | - $this->appId, |
|
112 | - $widgetClass |
|
113 | - ); |
|
114 | - } |
|
115 | - |
|
116 | - public function registerService(string $name, callable $factory, bool $shared = true): void { |
|
117 | - $this->context->registerService( |
|
118 | - $this->appId, |
|
119 | - $name, |
|
120 | - $factory, |
|
121 | - $shared |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - public function registerServiceAlias(string $alias, string $target): void { |
|
126 | - $this->context->registerServiceAlias( |
|
127 | - $this->appId, |
|
128 | - $alias, |
|
129 | - $target |
|
130 | - ); |
|
131 | - } |
|
132 | - |
|
133 | - public function registerParameter(string $name, $value): void { |
|
134 | - $this->context->registerParameter( |
|
135 | - $this->appId, |
|
136 | - $name, |
|
137 | - $value |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - public function registerEventListener(string $event, string $listener, int $priority = 0): void { |
|
142 | - $this->context->registerEventListener( |
|
143 | - $this->appId, |
|
144 | - $event, |
|
145 | - $listener, |
|
146 | - $priority |
|
147 | - ); |
|
148 | - } |
|
149 | - |
|
150 | - public function registerMiddleware(string $class): void { |
|
151 | - $this->context->registerMiddleware( |
|
152 | - $this->appId, |
|
153 | - $class |
|
154 | - ); |
|
155 | - } |
|
156 | - |
|
157 | - public function registerSearchProvider(string $class): void { |
|
158 | - $this->context->registerSearchProvider( |
|
159 | - $this->appId, |
|
160 | - $class |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - public function registerAlternativeLogin(string $class): void { |
|
165 | - $this->context->registerAlternativeLogin( |
|
166 | - $this->appId, |
|
167 | - $class |
|
168 | - ); |
|
169 | - } |
|
170 | - |
|
171 | - public function registerInitialStateProvider(string $class): void { |
|
172 | - $this->context->registerInitialState( |
|
173 | - $this->appId, |
|
174 | - $class |
|
175 | - ); |
|
176 | - } |
|
177 | - }; |
|
178 | - } |
|
179 | - |
|
180 | - public function registerCapability(string $appId, string $capability): void { |
|
181 | - $this->capabilities[] = [ |
|
182 | - 'appId' => $appId, |
|
183 | - 'capability' => $capability |
|
184 | - ]; |
|
185 | - } |
|
186 | - |
|
187 | - public function registerCrashReporter(string $appId, string $reporterClass): void { |
|
188 | - $this->crashReporters[] = [ |
|
189 | - 'appId' => $appId, |
|
190 | - 'class' => $reporterClass, |
|
191 | - ]; |
|
192 | - } |
|
193 | - |
|
194 | - public function registerDashboardPanel(string $appId, string $panelClass): void { |
|
195 | - $this->dashboardPanels[] = [ |
|
196 | - 'appId' => $appId, |
|
197 | - 'class' => $panelClass |
|
198 | - ]; |
|
199 | - } |
|
200 | - |
|
201 | - public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void { |
|
202 | - $this->services[] = [ |
|
203 | - "appId" => $appId, |
|
204 | - "name" => $name, |
|
205 | - "factory" => $factory, |
|
206 | - "shared" => $shared, |
|
207 | - ]; |
|
208 | - } |
|
209 | - |
|
210 | - public function registerServiceAlias(string $appId, string $alias, string $target): void { |
|
211 | - $this->aliases[] = [ |
|
212 | - "appId" => $appId, |
|
213 | - "alias" => $alias, |
|
214 | - "target" => $target, |
|
215 | - ]; |
|
216 | - } |
|
217 | - |
|
218 | - public function registerParameter(string $appId, string $name, $value): void { |
|
219 | - $this->parameters[] = [ |
|
220 | - "appId" => $appId, |
|
221 | - "name" => $name, |
|
222 | - "value" => $value, |
|
223 | - ]; |
|
224 | - } |
|
225 | - |
|
226 | - public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void { |
|
227 | - $this->eventListeners[] = [ |
|
228 | - "appId" => $appId, |
|
229 | - "event" => $event, |
|
230 | - "listener" => $listener, |
|
231 | - "priority" => $priority, |
|
232 | - ]; |
|
233 | - } |
|
234 | - |
|
235 | - public function registerMiddleware(string $appId, string $class): void { |
|
236 | - $this->middlewares[] = [ |
|
237 | - "appId" => $appId, |
|
238 | - "class" => $class, |
|
239 | - ]; |
|
240 | - } |
|
241 | - |
|
242 | - public function registerSearchProvider(string $appId, string $class) { |
|
243 | - $this->searchProviders[] = [ |
|
244 | - 'appId' => $appId, |
|
245 | - 'class' => $class, |
|
246 | - ]; |
|
247 | - } |
|
248 | - |
|
249 | - public function registerAlternativeLogin(string $appId, string $class): void { |
|
250 | - $this->alternativeLogins[] = [ |
|
251 | - 'appId' => $appId, |
|
252 | - 'class' => $class, |
|
253 | - ]; |
|
254 | - } |
|
255 | - |
|
256 | - public function registerInitialState(string $appId, string $class): void { |
|
257 | - $this->initialStates[] = [ |
|
258 | - 'appId' => $appId, |
|
259 | - 'class' => $class, |
|
260 | - ]; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * @param App[] $apps |
|
265 | - */ |
|
266 | - public function delegateCapabilityRegistrations(array $apps): void { |
|
267 | - while (($registration = array_shift($this->capabilities)) !== null) { |
|
268 | - try { |
|
269 | - $apps[$registration['appId']] |
|
270 | - ->getContainer() |
|
271 | - ->registerCapability($registration['capability']); |
|
272 | - } catch (Throwable $e) { |
|
273 | - $appId = $registration['appId']; |
|
274 | - $this->logger->logException($e, [ |
|
275 | - 'message' => "Error during capability registration of $appId: " . $e->getMessage(), |
|
276 | - 'level' => ILogger::ERROR, |
|
277 | - ]); |
|
278 | - } |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * @param App[] $apps |
|
284 | - */ |
|
285 | - public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void { |
|
286 | - while (($registration = array_shift($this->crashReporters)) !== null) { |
|
287 | - try { |
|
288 | - $registry->registerLazy($registration['class']); |
|
289 | - } catch (Throwable $e) { |
|
290 | - $appId = $registration['appId']; |
|
291 | - $this->logger->logException($e, [ |
|
292 | - 'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(), |
|
293 | - 'level' => ILogger::ERROR, |
|
294 | - ]); |
|
295 | - } |
|
296 | - } |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * @param App[] $apps |
|
301 | - */ |
|
302 | - public function delegateDashboardPanelRegistrations(array $apps, IManager $dashboardManager): void { |
|
303 | - while (($panel = array_shift($this->dashboardPanels)) !== null) { |
|
304 | - try { |
|
305 | - $dashboardManager->lazyRegisterWidget($panel['class']); |
|
306 | - } catch (Throwable $e) { |
|
307 | - $appId = $panel['appId']; |
|
308 | - $this->logger->logException($e, [ |
|
309 | - 'message' => "Error during dashboard registration of $appId: " . $e->getMessage(), |
|
310 | - 'level' => ILogger::ERROR, |
|
311 | - ]); |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void { |
|
317 | - while (($registration = array_shift($this->eventListeners)) !== null) { |
|
318 | - try { |
|
319 | - if (isset($registration['priority'])) { |
|
320 | - $eventDispatcher->addServiceListener( |
|
321 | - $registration['event'], |
|
322 | - $registration['listener'], |
|
323 | - $registration['priority'] |
|
324 | - ); |
|
325 | - } else { |
|
326 | - $eventDispatcher->addServiceListener( |
|
327 | - $registration['event'], |
|
328 | - $registration['listener'] |
|
329 | - ); |
|
330 | - } |
|
331 | - } catch (Throwable $e) { |
|
332 | - $appId = $registration['appId']; |
|
333 | - $this->logger->logException($e, [ |
|
334 | - 'message' => "Error during event listener registration of $appId: " . $e->getMessage(), |
|
335 | - 'level' => ILogger::ERROR, |
|
336 | - ]); |
|
337 | - } |
|
338 | - } |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * @param App[] $apps |
|
343 | - */ |
|
344 | - public function delegateContainerRegistrations(array $apps): void { |
|
345 | - while (($registration = array_shift($this->services)) !== null) { |
|
346 | - try { |
|
347 | - /** |
|
348 | - * Register the service and convert the callable into a \Closure if necessary |
|
349 | - */ |
|
350 | - $apps[$registration['appId']] |
|
351 | - ->getContainer() |
|
352 | - ->registerService( |
|
353 | - $registration['name'], |
|
354 | - Closure::fromCallable($registration['factory']), |
|
355 | - $registration['shared'] ?? true |
|
356 | - ); |
|
357 | - } catch (Throwable $e) { |
|
358 | - $appId = $registration['appId']; |
|
359 | - $this->logger->logException($e, [ |
|
360 | - 'message' => "Error during service registration of $appId: " . $e->getMessage(), |
|
361 | - 'level' => ILogger::ERROR, |
|
362 | - ]); |
|
363 | - } |
|
364 | - } |
|
365 | - |
|
366 | - foreach ($this->aliases as $registration) { |
|
367 | - try { |
|
368 | - $apps[$registration['appId']] |
|
369 | - ->getContainer() |
|
370 | - ->registerAlias( |
|
371 | - $registration['alias'], |
|
372 | - $registration['target'] |
|
373 | - ); |
|
374 | - } catch (Throwable $e) { |
|
375 | - $appId = $registration['appId']; |
|
376 | - $this->logger->logException($e, [ |
|
377 | - 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), |
|
378 | - 'level' => ILogger::ERROR, |
|
379 | - ]); |
|
380 | - } |
|
381 | - } |
|
382 | - |
|
383 | - foreach ($this->parameters as $registration) { |
|
384 | - try { |
|
385 | - $apps[$registration['appId']] |
|
386 | - ->getContainer() |
|
387 | - ->registerParameter( |
|
388 | - $registration['name'], |
|
389 | - $registration['value'] |
|
390 | - ); |
|
391 | - } catch (Throwable $e) { |
|
392 | - $appId = $registration['appId']; |
|
393 | - $this->logger->logException($e, [ |
|
394 | - 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), |
|
395 | - 'level' => ILogger::ERROR, |
|
396 | - ]); |
|
397 | - } |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * @param App[] $apps |
|
403 | - */ |
|
404 | - public function delegateMiddlewareRegistrations(array $apps): void { |
|
405 | - while (($middleware = array_shift($this->middlewares)) !== null) { |
|
406 | - try { |
|
407 | - $apps[$middleware['appId']] |
|
408 | - ->getContainer() |
|
409 | - ->registerMiddleWare($middleware['class']); |
|
410 | - } catch (Throwable $e) { |
|
411 | - $appId = $middleware['appId']; |
|
412 | - $this->logger->logException($e, [ |
|
413 | - 'message' => "Error during capability registration of $appId: " . $e->getMessage(), |
|
414 | - 'level' => ILogger::ERROR, |
|
415 | - ]); |
|
416 | - } |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * @return array[] |
|
422 | - */ |
|
423 | - public function getSearchProviders(): array { |
|
424 | - return $this->searchProviders; |
|
425 | - } |
|
426 | - |
|
427 | - /** |
|
428 | - * @return array[] |
|
429 | - */ |
|
430 | - public function getAlternativeLogins(): array { |
|
431 | - return $this->alternativeLogins; |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * @erturn array[] |
|
436 | - */ |
|
437 | - public function getInitialStates(): array { |
|
438 | - return $this->initialStates; |
|
439 | - } |
|
42 | + /** @var array[] */ |
|
43 | + private $capabilities = []; |
|
44 | + |
|
45 | + /** @var array[] */ |
|
46 | + private $crashReporters = []; |
|
47 | + |
|
48 | + /** @var array[] */ |
|
49 | + private $dashboardPanels = []; |
|
50 | + |
|
51 | + /** @var array[] */ |
|
52 | + private $services = []; |
|
53 | + |
|
54 | + /** @var array[] */ |
|
55 | + private $aliases = []; |
|
56 | + |
|
57 | + /** @var array[] */ |
|
58 | + private $parameters = []; |
|
59 | + |
|
60 | + /** @var array[] */ |
|
61 | + private $eventListeners = []; |
|
62 | + |
|
63 | + /** @var array[] */ |
|
64 | + private $middlewares = []; |
|
65 | + |
|
66 | + /** @var array[] */ |
|
67 | + private $searchProviders = []; |
|
68 | + |
|
69 | + /** @var array[] */ |
|
70 | + private $alternativeLogins = []; |
|
71 | + |
|
72 | + /** @var array[] */ |
|
73 | + private $initialStates = []; |
|
74 | + |
|
75 | + /** @var ILogger */ |
|
76 | + private $logger; |
|
77 | + |
|
78 | + public function __construct(ILogger $logger) { |
|
79 | + $this->logger = $logger; |
|
80 | + } |
|
81 | + |
|
82 | + public function for(string $appId): IRegistrationContext { |
|
83 | + return new class($appId, $this) implements IRegistrationContext { |
|
84 | + /** @var string */ |
|
85 | + private $appId; |
|
86 | + |
|
87 | + /** @var RegistrationContext */ |
|
88 | + private $context; |
|
89 | + |
|
90 | + public function __construct(string $appId, RegistrationContext $context) { |
|
91 | + $this->appId = $appId; |
|
92 | + $this->context = $context; |
|
93 | + } |
|
94 | + |
|
95 | + public function registerCapability(string $capability): void { |
|
96 | + $this->context->registerCapability( |
|
97 | + $this->appId, |
|
98 | + $capability |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + public function registerCrashReporter(string $reporterClass): void { |
|
103 | + $this->context->registerCrashReporter( |
|
104 | + $this->appId, |
|
105 | + $reporterClass |
|
106 | + ); |
|
107 | + } |
|
108 | + |
|
109 | + public function registerDashboardWidget(string $widgetClass): void { |
|
110 | + $this->context->registerDashboardPanel( |
|
111 | + $this->appId, |
|
112 | + $widgetClass |
|
113 | + ); |
|
114 | + } |
|
115 | + |
|
116 | + public function registerService(string $name, callable $factory, bool $shared = true): void { |
|
117 | + $this->context->registerService( |
|
118 | + $this->appId, |
|
119 | + $name, |
|
120 | + $factory, |
|
121 | + $shared |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + public function registerServiceAlias(string $alias, string $target): void { |
|
126 | + $this->context->registerServiceAlias( |
|
127 | + $this->appId, |
|
128 | + $alias, |
|
129 | + $target |
|
130 | + ); |
|
131 | + } |
|
132 | + |
|
133 | + public function registerParameter(string $name, $value): void { |
|
134 | + $this->context->registerParameter( |
|
135 | + $this->appId, |
|
136 | + $name, |
|
137 | + $value |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + public function registerEventListener(string $event, string $listener, int $priority = 0): void { |
|
142 | + $this->context->registerEventListener( |
|
143 | + $this->appId, |
|
144 | + $event, |
|
145 | + $listener, |
|
146 | + $priority |
|
147 | + ); |
|
148 | + } |
|
149 | + |
|
150 | + public function registerMiddleware(string $class): void { |
|
151 | + $this->context->registerMiddleware( |
|
152 | + $this->appId, |
|
153 | + $class |
|
154 | + ); |
|
155 | + } |
|
156 | + |
|
157 | + public function registerSearchProvider(string $class): void { |
|
158 | + $this->context->registerSearchProvider( |
|
159 | + $this->appId, |
|
160 | + $class |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + public function registerAlternativeLogin(string $class): void { |
|
165 | + $this->context->registerAlternativeLogin( |
|
166 | + $this->appId, |
|
167 | + $class |
|
168 | + ); |
|
169 | + } |
|
170 | + |
|
171 | + public function registerInitialStateProvider(string $class): void { |
|
172 | + $this->context->registerInitialState( |
|
173 | + $this->appId, |
|
174 | + $class |
|
175 | + ); |
|
176 | + } |
|
177 | + }; |
|
178 | + } |
|
179 | + |
|
180 | + public function registerCapability(string $appId, string $capability): void { |
|
181 | + $this->capabilities[] = [ |
|
182 | + 'appId' => $appId, |
|
183 | + 'capability' => $capability |
|
184 | + ]; |
|
185 | + } |
|
186 | + |
|
187 | + public function registerCrashReporter(string $appId, string $reporterClass): void { |
|
188 | + $this->crashReporters[] = [ |
|
189 | + 'appId' => $appId, |
|
190 | + 'class' => $reporterClass, |
|
191 | + ]; |
|
192 | + } |
|
193 | + |
|
194 | + public function registerDashboardPanel(string $appId, string $panelClass): void { |
|
195 | + $this->dashboardPanels[] = [ |
|
196 | + 'appId' => $appId, |
|
197 | + 'class' => $panelClass |
|
198 | + ]; |
|
199 | + } |
|
200 | + |
|
201 | + public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void { |
|
202 | + $this->services[] = [ |
|
203 | + "appId" => $appId, |
|
204 | + "name" => $name, |
|
205 | + "factory" => $factory, |
|
206 | + "shared" => $shared, |
|
207 | + ]; |
|
208 | + } |
|
209 | + |
|
210 | + public function registerServiceAlias(string $appId, string $alias, string $target): void { |
|
211 | + $this->aliases[] = [ |
|
212 | + "appId" => $appId, |
|
213 | + "alias" => $alias, |
|
214 | + "target" => $target, |
|
215 | + ]; |
|
216 | + } |
|
217 | + |
|
218 | + public function registerParameter(string $appId, string $name, $value): void { |
|
219 | + $this->parameters[] = [ |
|
220 | + "appId" => $appId, |
|
221 | + "name" => $name, |
|
222 | + "value" => $value, |
|
223 | + ]; |
|
224 | + } |
|
225 | + |
|
226 | + public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void { |
|
227 | + $this->eventListeners[] = [ |
|
228 | + "appId" => $appId, |
|
229 | + "event" => $event, |
|
230 | + "listener" => $listener, |
|
231 | + "priority" => $priority, |
|
232 | + ]; |
|
233 | + } |
|
234 | + |
|
235 | + public function registerMiddleware(string $appId, string $class): void { |
|
236 | + $this->middlewares[] = [ |
|
237 | + "appId" => $appId, |
|
238 | + "class" => $class, |
|
239 | + ]; |
|
240 | + } |
|
241 | + |
|
242 | + public function registerSearchProvider(string $appId, string $class) { |
|
243 | + $this->searchProviders[] = [ |
|
244 | + 'appId' => $appId, |
|
245 | + 'class' => $class, |
|
246 | + ]; |
|
247 | + } |
|
248 | + |
|
249 | + public function registerAlternativeLogin(string $appId, string $class): void { |
|
250 | + $this->alternativeLogins[] = [ |
|
251 | + 'appId' => $appId, |
|
252 | + 'class' => $class, |
|
253 | + ]; |
|
254 | + } |
|
255 | + |
|
256 | + public function registerInitialState(string $appId, string $class): void { |
|
257 | + $this->initialStates[] = [ |
|
258 | + 'appId' => $appId, |
|
259 | + 'class' => $class, |
|
260 | + ]; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * @param App[] $apps |
|
265 | + */ |
|
266 | + public function delegateCapabilityRegistrations(array $apps): void { |
|
267 | + while (($registration = array_shift($this->capabilities)) !== null) { |
|
268 | + try { |
|
269 | + $apps[$registration['appId']] |
|
270 | + ->getContainer() |
|
271 | + ->registerCapability($registration['capability']); |
|
272 | + } catch (Throwable $e) { |
|
273 | + $appId = $registration['appId']; |
|
274 | + $this->logger->logException($e, [ |
|
275 | + 'message' => "Error during capability registration of $appId: " . $e->getMessage(), |
|
276 | + 'level' => ILogger::ERROR, |
|
277 | + ]); |
|
278 | + } |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * @param App[] $apps |
|
284 | + */ |
|
285 | + public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void { |
|
286 | + while (($registration = array_shift($this->crashReporters)) !== null) { |
|
287 | + try { |
|
288 | + $registry->registerLazy($registration['class']); |
|
289 | + } catch (Throwable $e) { |
|
290 | + $appId = $registration['appId']; |
|
291 | + $this->logger->logException($e, [ |
|
292 | + 'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(), |
|
293 | + 'level' => ILogger::ERROR, |
|
294 | + ]); |
|
295 | + } |
|
296 | + } |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * @param App[] $apps |
|
301 | + */ |
|
302 | + public function delegateDashboardPanelRegistrations(array $apps, IManager $dashboardManager): void { |
|
303 | + while (($panel = array_shift($this->dashboardPanels)) !== null) { |
|
304 | + try { |
|
305 | + $dashboardManager->lazyRegisterWidget($panel['class']); |
|
306 | + } catch (Throwable $e) { |
|
307 | + $appId = $panel['appId']; |
|
308 | + $this->logger->logException($e, [ |
|
309 | + 'message' => "Error during dashboard registration of $appId: " . $e->getMessage(), |
|
310 | + 'level' => ILogger::ERROR, |
|
311 | + ]); |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void { |
|
317 | + while (($registration = array_shift($this->eventListeners)) !== null) { |
|
318 | + try { |
|
319 | + if (isset($registration['priority'])) { |
|
320 | + $eventDispatcher->addServiceListener( |
|
321 | + $registration['event'], |
|
322 | + $registration['listener'], |
|
323 | + $registration['priority'] |
|
324 | + ); |
|
325 | + } else { |
|
326 | + $eventDispatcher->addServiceListener( |
|
327 | + $registration['event'], |
|
328 | + $registration['listener'] |
|
329 | + ); |
|
330 | + } |
|
331 | + } catch (Throwable $e) { |
|
332 | + $appId = $registration['appId']; |
|
333 | + $this->logger->logException($e, [ |
|
334 | + 'message' => "Error during event listener registration of $appId: " . $e->getMessage(), |
|
335 | + 'level' => ILogger::ERROR, |
|
336 | + ]); |
|
337 | + } |
|
338 | + } |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * @param App[] $apps |
|
343 | + */ |
|
344 | + public function delegateContainerRegistrations(array $apps): void { |
|
345 | + while (($registration = array_shift($this->services)) !== null) { |
|
346 | + try { |
|
347 | + /** |
|
348 | + * Register the service and convert the callable into a \Closure if necessary |
|
349 | + */ |
|
350 | + $apps[$registration['appId']] |
|
351 | + ->getContainer() |
|
352 | + ->registerService( |
|
353 | + $registration['name'], |
|
354 | + Closure::fromCallable($registration['factory']), |
|
355 | + $registration['shared'] ?? true |
|
356 | + ); |
|
357 | + } catch (Throwable $e) { |
|
358 | + $appId = $registration['appId']; |
|
359 | + $this->logger->logException($e, [ |
|
360 | + 'message' => "Error during service registration of $appId: " . $e->getMessage(), |
|
361 | + 'level' => ILogger::ERROR, |
|
362 | + ]); |
|
363 | + } |
|
364 | + } |
|
365 | + |
|
366 | + foreach ($this->aliases as $registration) { |
|
367 | + try { |
|
368 | + $apps[$registration['appId']] |
|
369 | + ->getContainer() |
|
370 | + ->registerAlias( |
|
371 | + $registration['alias'], |
|
372 | + $registration['target'] |
|
373 | + ); |
|
374 | + } catch (Throwable $e) { |
|
375 | + $appId = $registration['appId']; |
|
376 | + $this->logger->logException($e, [ |
|
377 | + 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), |
|
378 | + 'level' => ILogger::ERROR, |
|
379 | + ]); |
|
380 | + } |
|
381 | + } |
|
382 | + |
|
383 | + foreach ($this->parameters as $registration) { |
|
384 | + try { |
|
385 | + $apps[$registration['appId']] |
|
386 | + ->getContainer() |
|
387 | + ->registerParameter( |
|
388 | + $registration['name'], |
|
389 | + $registration['value'] |
|
390 | + ); |
|
391 | + } catch (Throwable $e) { |
|
392 | + $appId = $registration['appId']; |
|
393 | + $this->logger->logException($e, [ |
|
394 | + 'message' => "Error during service alias registration of $appId: " . $e->getMessage(), |
|
395 | + 'level' => ILogger::ERROR, |
|
396 | + ]); |
|
397 | + } |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * @param App[] $apps |
|
403 | + */ |
|
404 | + public function delegateMiddlewareRegistrations(array $apps): void { |
|
405 | + while (($middleware = array_shift($this->middlewares)) !== null) { |
|
406 | + try { |
|
407 | + $apps[$middleware['appId']] |
|
408 | + ->getContainer() |
|
409 | + ->registerMiddleWare($middleware['class']); |
|
410 | + } catch (Throwable $e) { |
|
411 | + $appId = $middleware['appId']; |
|
412 | + $this->logger->logException($e, [ |
|
413 | + 'message' => "Error during capability registration of $appId: " . $e->getMessage(), |
|
414 | + 'level' => ILogger::ERROR, |
|
415 | + ]); |
|
416 | + } |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * @return array[] |
|
422 | + */ |
|
423 | + public function getSearchProviders(): array { |
|
424 | + return $this->searchProviders; |
|
425 | + } |
|
426 | + |
|
427 | + /** |
|
428 | + * @return array[] |
|
429 | + */ |
|
430 | + public function getAlternativeLogins(): array { |
|
431 | + return $this->alternativeLogins; |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * @erturn array[] |
|
436 | + */ |
|
437 | + public function getInitialStates(): array { |
|
438 | + return $this->initialStates; |
|
439 | + } |
|
440 | 440 | } |