Passed
Push — master ( 25406e...6c0bb2 )
by Morris
64:29 queued 52:03
created

RegistrationContext   F

Complexity

Total Complexity 61

Size/Duplication

Total Lines 449
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 449
rs 3.52
c 0
b 0
f 0
eloc 180
wmc 61

63 Methods

Rating   Name   Duplication   Size   Complexity  
registerWellKnown() 0 2 ?
A hp$0 ➔ getWellKnownHandlers() 0 2 1
getAlternativeLogins() 0 2 ?
A __construct() 0 2 1
registerAlternativeLogin() 0 2 ?
delegateDashboardPanelRegistrations() 0 9 ?
getTemplateProviders() 0 2 ?
A hp$0 ➔ registerTemplateProvider() 0 4 1
registerCapability() 0 2 ?
getInitialStates() 0 2 ?
A hp$0 ➔ registerDashboardPanel() 0 2 1
A hp$0 ➔ registerNotifierService() 0 4 1
registerServiceAlias() 0 2 ?
delegateMiddlewareRegistrations() 0 11 ?
A hp$0 ➔ delegateDashboardPanelRegistrations() 0 9 3
A hp$0 ➔ registerServiceAlias() 0 5 1
A hp$0 ➔ getInitialStates() 0 2 1
registerService() 0 2 ?
A hp$0 ➔ __construct() 0 3 1
A hp$0 ➔ getSearchProviders() 0 2 1
A hp$0 ➔ registerCapability() 0 4 1
registerEventListener() 0 2 ?
A hp$0 ➔ registerWellKnown() 0 2 1
A hp$0 ➔ delegateMiddlewareRegistrations() 0 11 3
A hp$0 ➔ registerDashboardWidget() 0 4 1
registerParameter() 0 2 ?
registerDashboardPanel() 0 2 ?
B hp$0 ➔ for() 0 121 1
registerTemplateProvider() 0 2 ?
A hp$0 ➔ getAlternativeLogins() 0 2 1
A hp$0 ➔ registerMiddleware() 0 4 1
A hp$0 ➔ getTwoFactorProviders() 0 2 1
A hp$0 ➔ registerAlternativeLogin() 0 4 1
getTwoFactorProviders() 0 2 ?
registerInitialState() 0 2 ?
A hp$0 ➔ registerEventListener() 0 6 1
delegateContainerRegistrations() 0 52 ?
A hp$0 ➔ registerCrashReporter() 0 4 1
A hp$0 ➔ registerInitialStateProvider() 0 4 1
getWellKnownHandlers() 0 2 ?
registerMiddleware() 0 2 ?
getSearchProviders() 0 2 ?
registerSearchProvider() 0 2 ?
A hp$0 ➔ getTemplateProviders() 0 2 1
A hp$0 ➔ delegateCapabilityRegistrations() 0 11 3
A hp$0 ➔ registerParameter() 0 5 1
B hp$0 ➔ delegateContainerRegistrations() 0 52 7
registerNotifierService() 0 2 ?
A hp$0 ➔ registerService() 0 6 1
registerCrashReporter() 0 2 ?
delegateCapabilityRegistrations() 0 11 ?
for() 0 121 ?
A hp$0 ➔ getNotifierServices() 0 2 1
A hp$0 ➔ registerSearchProvider() 0 4 1
getNotifierServices() 0 2 ?
A hp$0 ➔ registerWellKnownHandler() 0 4 1
A hp$0 ➔ delegateCrashReporterRegistrations() 0 9 3
A hp$0 ➔ registerInitialState() 0 2 1
A hp$0 ➔ registerTwoFactorProvider() 0 4 1
A hp$0 ➔ delegateEventListenerRegistrations() 0 13 3
delegateEventListenerRegistrations() 0 13 ?
registerTwoFactorProvider() 0 2 ?
delegateCrashReporterRegistrations() 0 9 ?

How to fix   Complexity   

Complex Class

Complex classes like RegistrationContext often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use RegistrationContext, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright 2020 Christoph Wurst <[email protected]>
7
 *
8
 * @author Christoph Wurst <[email protected]>
9
 * @author Joas Schilling <[email protected]>
10
 * @author Julius Härtl <[email protected]>
11
 * @author Robin Windey <[email protected]>
12
 * @author Roeland Jago Douma <[email protected]>
13
 *
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
31
namespace OC\AppFramework\Bootstrap;
32
33
use Closure;
34
use OC\Support\CrashReport\Registry;
35
use OCP\AppFramework\App;
36
use OCP\AppFramework\Bootstrap\IRegistrationContext;
37
use OCP\AppFramework\Middleware;
38
use OCP\AppFramework\Services\InitialStateProvider;
39
use OCP\Authentication\IAlternativeLogin;
40
use OCP\Capabilities\ICapability;
41
use OCP\Dashboard\IManager;
42
use OCP\Dashboard\IWidget;
43
use OCP\EventDispatcher\IEventDispatcher;
44
use OCP\Files\Template\ICustomTemplateProvider;
45
use OCP\Http\WellKnown\IHandler;
46
use OCP\ILogger;
47
use OCP\Notification\INotifier;
48
use OCP\Search\IProvider;
49
use OCP\Support\CrashReport\IReporter;
50
use Throwable;
51
use function array_shift;
52
53
class RegistrationContext {
54
55
	/** @var ServiceRegistration<ICapability>[] */
56
	private $capabilities = [];
57
58
	/** @var ServiceRegistration<IReporter>[] */
59
	private $crashReporters = [];
60
61
	/** @var ServiceRegistration<IWidget>[] */
62
	private $dashboardPanels = [];
63
64
	/** @var ServiceFactoryRegistration[] */
65
	private $services = [];
66
67
	/** @var ServiceAliasRegistration[] */
68
	private $aliases = [];
69
70
	/** @var ParameterRegistration[] */
71
	private $parameters = [];
72
73
	/** @var EventListenerRegistration[] */
74
	private $eventListeners = [];
75
76
	/** @var ServiceRegistration<Middleware>[] */
77
	private $middlewares = [];
78
79
	/** @var ServiceRegistration<IProvider>[] */
80
	private $searchProviders = [];
81
82
	/** @var ServiceRegistration<IAlternativeLogin>[] */
83
	private $alternativeLogins = [];
84
85
	/** @var ServiceRegistration<InitialStateProvider>[] */
86
	private $initialStates = [];
87
88
	/** @var ServiceRegistration<IHandler>[] */
89
	private $wellKnownHandlers = [];
90
91
	/** @var ServiceRegistration<ICustomTemplateProvider>[] */
92
	private $templateProviders = [];
93
94
	/** @var ServiceRegistration<INotifier>[] */
95
	private $notifierServices = [];
96
97
	/** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */
98
	private $twoFactorProviders = [];
99
100
	/** @var ILogger */
101
	private $logger;
102
103
	public function __construct(ILogger $logger) {
104
		$this->logger = $logger;
105
	}
106
107
	public function for(string $appId): IRegistrationContext {
108
		return new class($appId, $this) implements IRegistrationContext {
109
			/** @var string */
110
			private $appId;
111
112
			/** @var RegistrationContext */
113
			private $context;
114
115
			public function __construct(string $appId, RegistrationContext $context) {
116
				$this->appId = $appId;
117
				$this->context = $context;
118
			}
119
120
			public function registerCapability(string $capability): void {
121
				$this->context->registerCapability(
122
					$this->appId,
123
					$capability
124
				);
125
			}
126
127
			public function registerCrashReporter(string $reporterClass): void {
128
				$this->context->registerCrashReporter(
129
					$this->appId,
130
					$reporterClass
131
				);
132
			}
133
134
			public function registerDashboardWidget(string $widgetClass): void {
135
				$this->context->registerDashboardPanel(
136
					$this->appId,
137
					$widgetClass
138
				);
139
			}
140
141
			public function registerService(string $name, callable $factory, bool $shared = true): void {
142
				$this->context->registerService(
143
					$this->appId,
144
					$name,
145
					$factory,
146
					$shared
147
				);
148
			}
149
150
			public function registerServiceAlias(string $alias, string $target): void {
151
				$this->context->registerServiceAlias(
152
					$this->appId,
153
					$alias,
154
					$target
155
				);
156
			}
157
158
			public function registerParameter(string $name, $value): void {
159
				$this->context->registerParameter(
160
					$this->appId,
161
					$name,
162
					$value
163
				);
164
			}
165
166
			public function registerEventListener(string $event, string $listener, int $priority = 0): void {
167
				$this->context->registerEventListener(
168
					$this->appId,
169
					$event,
170
					$listener,
171
					$priority
172
				);
173
			}
174
175
			public function registerMiddleware(string $class): void {
176
				$this->context->registerMiddleware(
177
					$this->appId,
178
					$class
179
				);
180
			}
181
182
			public function registerSearchProvider(string $class): void {
183
				$this->context->registerSearchProvider(
184
					$this->appId,
185
					$class
186
				);
187
			}
188
189
			public function registerAlternativeLogin(string $class): void {
190
				$this->context->registerAlternativeLogin(
191
					$this->appId,
192
					$class
193
				);
194
			}
195
196
			public function registerInitialStateProvider(string $class): void {
197
				$this->context->registerInitialState(
198
					$this->appId,
199
					$class
200
				);
201
			}
202
203
			public function registerWellKnownHandler(string $class): void {
204
				$this->context->registerWellKnown(
205
					$this->appId,
206
					$class
207
				);
208
			}
209
210
			public function registerTemplateProvider(string $providerClass): void {
211
				$this->context->registerTemplateProvider(
212
					$this->appId,
213
					$providerClass
214
				);
215
			}
216
217
			public function registerNotifierService(string $notifierClass): void {
218
				$this->context->registerNotifierService(
219
					$this->appId,
220
					$notifierClass
221
				);
222
			}
223
224
			public function registerTwoFactorProvider(string $twoFactorProviderClass): void {
225
				$this->context->registerTwoFactorProvider(
226
					$this->appId,
227
					$twoFactorProviderClass
228
				);
229
			}
230
		};
231
	}
232
233
	/**
234
	 * @psalm-param class-string<ICapability> $capability
235
	 */
236
	public function registerCapability(string $appId, string $capability): void {
237
		$this->capabilities[] = new ServiceRegistration($appId, $capability);
238
	}
239
240
	/**
241
	 * @psalm-param class-string<IReporter> $capability
242
	 */
243
	public function registerCrashReporter(string $appId, string $reporterClass): void {
244
		$this->crashReporters[] = new ServiceRegistration($appId, $reporterClass);
245
	}
246
247
	/**
248
	 * @psalm-param class-string<IWidget> $capability
249
	 */
250
	public function registerDashboardPanel(string $appId, string $panelClass): void {
251
		$this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass);
252
	}
253
254
	public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
255
		$this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared);
256
	}
257
258
	public function registerServiceAlias(string $appId, string $alias, string $target): void {
259
		$this->aliases[] = new ServiceAliasRegistration($appId, $alias, $target);
260
	}
261
262
	public function registerParameter(string $appId, string $name, $value): void {
263
		$this->parameters[] = new ParameterRegistration($appId, $name, $value);
264
	}
265
266
	public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
267
		$this->eventListeners[] = new EventListenerRegistration($appId, $event, $listener, $priority);
268
	}
269
270
	/**
271
	 * @psalm-param class-string<Middleware> $class
272
	 */
273
	public function registerMiddleware(string $appId, string $class): void {
274
		$this->middlewares[] = new ServiceRegistration($appId, $class);
275
	}
276
277
	public function registerSearchProvider(string $appId, string $class) {
278
		$this->searchProviders[] = new ServiceRegistration($appId, $class);
279
	}
280
281
	public function registerAlternativeLogin(string $appId, string $class): void {
282
		$this->alternativeLogins[] = new ServiceRegistration($appId, $class);
283
	}
284
285
	public function registerInitialState(string $appId, string $class): void {
286
		$this->initialStates[] = new ServiceRegistration($appId, $class);
287
	}
288
289
	public function registerWellKnown(string $appId, string $class): void {
290
		$this->wellKnownHandlers[] = new ServiceRegistration($appId, $class);
291
	}
292
293
	public function registerTemplateProvider(string $appId, string $class): void {
294
		$this->templateProviders[] = new ServiceRegistration($appId, $class);
295
	}
296
297
	public function registerNotifierService(string $appId, string $class): void {
298
		$this->notifierServices[] = new ServiceRegistration($appId, $class);
299
	}
300
301
	public function registerTwoFactorProvider(string $appId, string $class): void {
302
		$this->twoFactorProviders[] = new ServiceRegistration($appId, $class);
303
	}
304
305
	/**
306
	 * @param App[] $apps
307
	 */
308
	public function delegateCapabilityRegistrations(array $apps): void {
309
		while (($registration = array_shift($this->capabilities)) !== null) {
0 ignored issues
show
Bug introduced by
$this->capabilities of type OC\AppFramework\Bootstrap\ServiceRegistration is incompatible with the type array expected by parameter $array of array_shift(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

309
		while (($registration = array_shift(/** @scrutinizer ignore-type */ $this->capabilities)) !== null) {
Loading history...
310
			try {
311
				$apps[$registration->getAppId()]
312
					->getContainer()
313
					->registerCapability($registration->getService());
314
			} catch (Throwable $e) {
315
				$appId = $registration->getAppId();
316
				$this->logger->logException($e, [
317
					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
318
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

318
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
319
				]);
320
			}
321
		}
322
	}
323
324
	/**
325
	 * @param App[] $apps
326
	 */
327
	public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
0 ignored issues
show
Unused Code introduced by
The parameter $apps is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

327
	public function delegateCrashReporterRegistrations(/** @scrutinizer ignore-unused */ array $apps, Registry $registry): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
328
		while (($registration = array_shift($this->crashReporters)) !== null) {
0 ignored issues
show
Bug introduced by
$this->crashReporters of type OC\AppFramework\Bootstrap\ServiceRegistration is incompatible with the type array expected by parameter $array of array_shift(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

328
		while (($registration = array_shift(/** @scrutinizer ignore-type */ $this->crashReporters)) !== null) {
Loading history...
329
			try {
330
				$registry->registerLazy($registration->getService());
331
			} catch (Throwable $e) {
332
				$appId = $registration->getAppId();
333
				$this->logger->logException($e, [
334
					'message' => "Error during crash reporter registration of $appId: " . $e->getMessage(),
335
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

335
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
336
				]);
337
			}
338
		}
339
	}
340
341
	/**
342
	 * @param App[] $apps
343
	 */
344
	public function delegateDashboardPanelRegistrations(array $apps, IManager $dashboardManager): void {
0 ignored issues
show
Unused Code introduced by
The parameter $apps is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

344
	public function delegateDashboardPanelRegistrations(/** @scrutinizer ignore-unused */ array $apps, IManager $dashboardManager): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
345
		while (($panel = array_shift($this->dashboardPanels)) !== null) {
0 ignored issues
show
Bug introduced by
$this->dashboardPanels of type OC\AppFramework\Bootstrap\ServiceRegistration is incompatible with the type array expected by parameter $array of array_shift(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

345
		while (($panel = array_shift(/** @scrutinizer ignore-type */ $this->dashboardPanels)) !== null) {
Loading history...
346
			try {
347
				$dashboardManager->lazyRegisterWidget($panel->getService());
348
			} catch (Throwable $e) {
349
				$appId = $panel->getAppId();
350
				$this->logger->logException($e, [
351
					'message' => "Error during dashboard registration of $appId: " . $e->getMessage(),
352
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

352
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
353
				]);
354
			}
355
		}
356
	}
357
358
	public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
359
		while (($registration = array_shift($this->eventListeners)) !== null) {
360
			try {
361
				$eventDispatcher->addServiceListener(
362
					$registration->getEvent(),
363
					$registration->getService(),
364
					$registration->getPriority()
365
				);
366
			} catch (Throwable $e) {
367
				$appId = $registration->getAppId();
368
				$this->logger->logException($e, [
369
					'message' => "Error during event listener registration of $appId: " . $e->getMessage(),
370
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

370
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
371
				]);
372
			}
373
		}
374
	}
375
376
	/**
377
	 * @param App[] $apps
378
	 */
379
	public function delegateContainerRegistrations(array $apps): void {
380
		while (($registration = array_shift($this->services)) !== null) {
381
			try {
382
				/**
383
				 * Register the service and convert the callable into a \Closure if necessary
384
				 */
385
				$apps[$registration->getAppId()]
386
					->getContainer()
387
					->registerService(
388
						$registration->getName(),
389
						Closure::fromCallable($registration->getFactory()),
390
						$registration->isShared()
391
					);
392
			} catch (Throwable $e) {
393
				$appId = $registration->getAppId();
394
				$this->logger->logException($e, [
395
					'message' => "Error during service registration of $appId: " . $e->getMessage(),
396
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

396
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
397
				]);
398
			}
399
		}
400
401
		while (($registration = array_shift($this->aliases)) !== null) {
402
			try {
403
				$apps[$registration->getAppId()]
404
					->getContainer()
405
					->registerAlias(
406
						$registration->getAlias(),
407
						$registration->getTarget()
408
					);
409
			} catch (Throwable $e) {
410
				$appId = $registration->getAppId();
411
				$this->logger->logException($e, [
412
					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
413
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

413
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
414
				]);
415
			}
416
		}
417
418
		while (($registration = array_shift($this->parameters)) !== null) {
419
			try {
420
				$apps[$registration->getAppId()]
421
					->getContainer()
422
					->registerParameter(
423
						$registration->getName(),
424
						$registration->getValue()
425
					);
426
			} catch (Throwable $e) {
427
				$appId = $registration->getAppId();
428
				$this->logger->logException($e, [
429
					'message' => "Error during service alias registration of $appId: " . $e->getMessage(),
430
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

430
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
431
				]);
432
			}
433
		}
434
	}
435
436
	/**
437
	 * @param App[] $apps
438
	 */
439
	public function delegateMiddlewareRegistrations(array $apps): void {
440
		while (($middleware = array_shift($this->middlewares)) !== null) {
0 ignored issues
show
Bug introduced by
$this->middlewares of type OC\AppFramework\Bootstrap\ServiceRegistration is incompatible with the type array expected by parameter $array of array_shift(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

440
		while (($middleware = array_shift(/** @scrutinizer ignore-type */ $this->middlewares)) !== null) {
Loading history...
441
			try {
442
				$apps[$middleware->getAppId()]
443
					->getContainer()
444
					->registerMiddleWare($middleware->getService());
445
			} catch (Throwable $e) {
446
				$appId = $middleware->getAppId();
447
				$this->logger->logException($e, [
448
					'message' => "Error during capability registration of $appId: " . $e->getMessage(),
449
					'level' => ILogger::ERROR,
0 ignored issues
show
Deprecated Code introduced by
The constant OCP\ILogger::ERROR has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

449
					'level' => /** @scrutinizer ignore-deprecated */ ILogger::ERROR,

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
450
				]);
451
			}
452
		}
453
	}
454
455
	/**
456
	 * @return ServiceRegistration<IProvider>[]
457
	 */
458
	public function getSearchProviders(): array {
459
		return $this->searchProviders;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->searchProviders returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
460
	}
461
462
	/**
463
	 * @return ServiceRegistration<IAlternativeLogin>[]
464
	 */
465
	public function getAlternativeLogins(): array {
466
		return $this->alternativeLogins;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->alternativeLogins returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
467
	}
468
469
	/**
470
	 * @return ServiceRegistration<InitialStateProvider>[]
471
	 */
472
	public function getInitialStates(): array {
473
		return $this->initialStates;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->initialStates returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
474
	}
475
476
	/**
477
	 * @return ServiceRegistration<IHandler>[]
478
	 */
479
	public function getWellKnownHandlers(): array {
480
		return $this->wellKnownHandlers;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->wellKnownHandlers returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
481
	}
482
483
	/**
484
	 * @return ServiceRegistration<ICustomTemplateProvider>[]
485
	 */
486
	public function getTemplateProviders(): array {
487
		return $this->templateProviders;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->templateProviders returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
488
	}
489
490
	/**
491
	 * @return ServiceRegistration<INotifier>[]
492
	 */
493
	public function getNotifierServices(): array {
494
		return $this->notifierServices;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->notifierServices returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
495
	}
496
497
	/**
498
	 * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[]
499
	 */
500
	public function getTwoFactorProviders(): array {
501
		return $this->twoFactorProviders;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->twoFactorProviders returns the type OC\AppFramework\Bootstrap\ServiceRegistration which is incompatible with the type-hinted return array.
Loading history...
502
	}
503
}
504