| Total Complexity | 95 |
| Total Lines | 699 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
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 |
||
| 60 | class RegistrationContext { |
||
| 61 | |||
| 62 | /** @var ServiceRegistration<ICapability>[] */ |
||
| 63 | private $capabilities = []; |
||
| 64 | |||
| 65 | /** @var ServiceRegistration<IReporter>[] */ |
||
| 66 | private $crashReporters = []; |
||
| 67 | |||
| 68 | /** @var ServiceRegistration<IWidget>[] */ |
||
| 69 | private $dashboardPanels = []; |
||
| 70 | |||
| 71 | /** @var ServiceRegistration<ILinkAction>[] */ |
||
| 72 | private $profileLinkActions = []; |
||
| 73 | |||
| 74 | /** @var null|ServiceRegistration<ITalkBackend> */ |
||
| 75 | private $talkBackendRegistration = null; |
||
| 76 | |||
| 77 | /** @var ServiceRegistration<IResourceBackend>[] */ |
||
| 78 | private $calendarResourceBackendRegistrations = []; |
||
| 79 | |||
| 80 | /** @var ServiceRegistration<IRoomBackend>[] */ |
||
| 81 | private $calendarRoomBackendRegistrations = []; |
||
| 82 | |||
| 83 | /** @var ServiceRegistration<IUserMigrator>[] */ |
||
| 84 | private $userMigrators = []; |
||
| 85 | |||
| 86 | /** @var ServiceFactoryRegistration[] */ |
||
| 87 | private $services = []; |
||
| 88 | |||
| 89 | /** @var ServiceAliasRegistration[] */ |
||
| 90 | private $aliases = []; |
||
| 91 | |||
| 92 | /** @var ParameterRegistration[] */ |
||
| 93 | private $parameters = []; |
||
| 94 | |||
| 95 | /** @var EventListenerRegistration[] */ |
||
| 96 | private $eventListeners = []; |
||
| 97 | |||
| 98 | /** @var ServiceRegistration<Middleware>[] */ |
||
| 99 | private $middlewares = []; |
||
| 100 | |||
| 101 | /** @var ServiceRegistration<IProvider>[] */ |
||
| 102 | private $searchProviders = []; |
||
| 103 | |||
| 104 | /** @var ServiceRegistration<IAlternativeLogin>[] */ |
||
| 105 | private $alternativeLogins = []; |
||
| 106 | |||
| 107 | /** @var ServiceRegistration<InitialStateProvider>[] */ |
||
| 108 | private $initialStates = []; |
||
| 109 | |||
| 110 | /** @var ServiceRegistration<IHandler>[] */ |
||
| 111 | private $wellKnownHandlers = []; |
||
| 112 | |||
| 113 | /** @var ServiceRegistration<ICustomTemplateProvider>[] */ |
||
| 114 | private $templateProviders = []; |
||
| 115 | |||
| 116 | /** @var ServiceRegistration<INotifier>[] */ |
||
| 117 | private $notifierServices = []; |
||
| 118 | |||
| 119 | /** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */ |
||
| 120 | private $twoFactorProviders = []; |
||
| 121 | |||
| 122 | /** @var ServiceRegistration<ICalendarProvider>[] */ |
||
| 123 | private $calendarProviders = []; |
||
| 124 | |||
| 125 | /** @var ServiceRegistration<IReferenceProvider>[] */ |
||
| 126 | private array $referenceProviders = []; |
||
| 127 | |||
| 128 | /** @var ParameterRegistration[] */ |
||
| 129 | private $sensitiveMethods = []; |
||
| 130 | |||
| 131 | /** @var LoggerInterface */ |
||
| 132 | private $logger; |
||
| 133 | |||
| 134 | /** @var PreviewProviderRegistration[] */ |
||
| 135 | private $previewProviders = []; |
||
| 136 | |||
| 137 | public function __construct(LoggerInterface $logger) { |
||
| 138 | $this->logger = $logger; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function for(string $appId): IRegistrationContext { |
||
| 142 | return new class($appId, $this) implements IRegistrationContext { |
||
| 143 | /** @var string */ |
||
| 144 | private $appId; |
||
| 145 | |||
| 146 | /** @var RegistrationContext */ |
||
| 147 | private $context; |
||
| 148 | |||
| 149 | public function __construct(string $appId, RegistrationContext $context) { |
||
| 150 | $this->appId = $appId; |
||
| 151 | $this->context = $context; |
||
| 152 | } |
||
| 153 | |||
| 154 | public function registerCapability(string $capability): void { |
||
| 155 | $this->context->registerCapability( |
||
| 156 | $this->appId, |
||
| 157 | $capability |
||
| 158 | ); |
||
| 159 | } |
||
| 160 | |||
| 161 | public function registerCrashReporter(string $reporterClass): void { |
||
| 162 | $this->context->registerCrashReporter( |
||
| 163 | $this->appId, |
||
| 164 | $reporterClass |
||
| 165 | ); |
||
| 166 | } |
||
| 167 | |||
| 168 | public function registerDashboardWidget(string $widgetClass): void { |
||
| 169 | $this->context->registerDashboardPanel( |
||
| 170 | $this->appId, |
||
| 171 | $widgetClass |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | |||
| 175 | public function registerService(string $name, callable $factory, bool $shared = true): void { |
||
| 176 | $this->context->registerService( |
||
| 177 | $this->appId, |
||
| 178 | $name, |
||
| 179 | $factory, |
||
| 180 | $shared |
||
| 181 | ); |
||
| 182 | } |
||
| 183 | |||
| 184 | public function registerServiceAlias(string $alias, string $target): void { |
||
| 185 | $this->context->registerServiceAlias( |
||
| 186 | $this->appId, |
||
| 187 | $alias, |
||
| 188 | $target |
||
| 189 | ); |
||
| 190 | } |
||
| 191 | |||
| 192 | public function registerParameter(string $name, $value): void { |
||
| 193 | $this->context->registerParameter( |
||
| 194 | $this->appId, |
||
| 195 | $name, |
||
| 196 | $value |
||
| 197 | ); |
||
| 198 | } |
||
| 199 | |||
| 200 | public function registerEventListener(string $event, string $listener, int $priority = 0): void { |
||
| 201 | $this->context->registerEventListener( |
||
| 202 | $this->appId, |
||
| 203 | $event, |
||
| 204 | $listener, |
||
| 205 | $priority |
||
| 206 | ); |
||
| 207 | } |
||
| 208 | |||
| 209 | public function registerMiddleware(string $class): void { |
||
| 210 | $this->context->registerMiddleware( |
||
| 211 | $this->appId, |
||
| 212 | $class |
||
| 213 | ); |
||
| 214 | } |
||
| 215 | |||
| 216 | public function registerSearchProvider(string $class): void { |
||
| 217 | $this->context->registerSearchProvider( |
||
| 218 | $this->appId, |
||
| 219 | $class |
||
| 220 | ); |
||
| 221 | } |
||
| 222 | |||
| 223 | public function registerAlternativeLogin(string $class): void { |
||
| 224 | $this->context->registerAlternativeLogin( |
||
| 225 | $this->appId, |
||
| 226 | $class |
||
| 227 | ); |
||
| 228 | } |
||
| 229 | |||
| 230 | public function registerInitialStateProvider(string $class): void { |
||
| 231 | $this->context->registerInitialState( |
||
| 232 | $this->appId, |
||
| 233 | $class |
||
| 234 | ); |
||
| 235 | } |
||
| 236 | |||
| 237 | public function registerWellKnownHandler(string $class): void { |
||
| 238 | $this->context->registerWellKnown( |
||
| 239 | $this->appId, |
||
| 240 | $class |
||
| 241 | ); |
||
| 242 | } |
||
| 243 | |||
| 244 | public function registerTemplateProvider(string $providerClass): void { |
||
| 245 | $this->context->registerTemplateProvider( |
||
| 246 | $this->appId, |
||
| 247 | $providerClass |
||
| 248 | ); |
||
| 249 | } |
||
| 250 | |||
| 251 | public function registerNotifierService(string $notifierClass): void { |
||
| 252 | $this->context->registerNotifierService( |
||
| 253 | $this->appId, |
||
| 254 | $notifierClass |
||
| 255 | ); |
||
| 256 | } |
||
| 257 | |||
| 258 | public function registerTwoFactorProvider(string $twoFactorProviderClass): void { |
||
| 259 | $this->context->registerTwoFactorProvider( |
||
| 260 | $this->appId, |
||
| 261 | $twoFactorProviderClass |
||
| 262 | ); |
||
| 263 | } |
||
| 264 | |||
| 265 | public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void { |
||
| 266 | $this->context->registerPreviewProvider( |
||
| 267 | $this->appId, |
||
| 268 | $previewProviderClass, |
||
| 269 | $mimeTypeRegex |
||
| 270 | ); |
||
| 271 | } |
||
| 272 | |||
| 273 | public function registerCalendarProvider(string $class): void { |
||
| 274 | $this->context->registerCalendarProvider( |
||
| 275 | $this->appId, |
||
| 276 | $class |
||
| 277 | ); |
||
| 278 | } |
||
| 279 | |||
| 280 | public function registerReferenceProvider(string $class): void { |
||
| 281 | $this->context->registerReferenceProvider( |
||
| 282 | $this->appId, |
||
| 283 | $class |
||
| 284 | ); |
||
| 285 | } |
||
| 286 | |||
| 287 | public function registerProfileLinkAction(string $actionClass): void { |
||
| 288 | $this->context->registerProfileLinkAction( |
||
| 289 | $this->appId, |
||
| 290 | $actionClass |
||
| 291 | ); |
||
| 292 | } |
||
| 293 | |||
| 294 | public function registerTalkBackend(string $backend): void { |
||
| 295 | $this->context->registerTalkBackend( |
||
| 296 | $this->appId, |
||
| 297 | $backend |
||
| 298 | ); |
||
| 299 | } |
||
| 300 | |||
| 301 | public function registerCalendarResourceBackend(string $class): void { |
||
| 302 | $this->context->registerCalendarResourceBackend( |
||
| 303 | $this->appId, |
||
| 304 | $class |
||
| 305 | ); |
||
| 306 | } |
||
| 307 | |||
| 308 | public function registerCalendarRoomBackend(string $class): void { |
||
| 309 | $this->context->registerCalendarRoomBackend( |
||
| 310 | $this->appId, |
||
| 311 | $class |
||
| 312 | ); |
||
| 313 | } |
||
| 314 | |||
| 315 | public function registerUserMigrator(string $migratorClass): void { |
||
| 316 | $this->context->registerUserMigrator( |
||
| 317 | $this->appId, |
||
| 318 | $migratorClass |
||
| 319 | ); |
||
| 320 | } |
||
| 321 | |||
| 322 | public function registerSensitiveMethods(string $class, array $methods): void { |
||
| 323 | $this->context->registerSensitiveMethods( |
||
| 324 | $this->appId, |
||
| 325 | $class, |
||
| 326 | $methods |
||
| 327 | ); |
||
| 328 | } |
||
| 329 | }; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @psalm-param class-string<ICapability> $capability |
||
| 334 | */ |
||
| 335 | public function registerCapability(string $appId, string $capability): void { |
||
| 336 | $this->capabilities[] = new ServiceRegistration($appId, $capability); |
||
| 337 | } |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @psalm-param class-string<IReporter> $capability |
||
| 341 | */ |
||
| 342 | public function registerCrashReporter(string $appId, string $reporterClass): void { |
||
| 343 | $this->crashReporters[] = new ServiceRegistration($appId, $reporterClass); |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * @psalm-param class-string<IWidget> $capability |
||
| 348 | */ |
||
| 349 | public function registerDashboardPanel(string $appId, string $panelClass): void { |
||
| 350 | $this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass); |
||
| 351 | } |
||
| 352 | |||
| 353 | public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void { |
||
| 354 | $this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared); |
||
| 355 | } |
||
| 356 | |||
| 357 | public function registerServiceAlias(string $appId, string $alias, string $target): void { |
||
| 358 | $this->aliases[] = new ServiceAliasRegistration($appId, $alias, $target); |
||
| 359 | } |
||
| 360 | |||
| 361 | public function registerParameter(string $appId, string $name, $value): void { |
||
| 362 | $this->parameters[] = new ParameterRegistration($appId, $name, $value); |
||
| 363 | } |
||
| 364 | |||
| 365 | public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void { |
||
| 366 | $this->eventListeners[] = new EventListenerRegistration($appId, $event, $listener, $priority); |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @psalm-param class-string<Middleware> $class |
||
| 371 | */ |
||
| 372 | public function registerMiddleware(string $appId, string $class): void { |
||
| 373 | $this->middlewares[] = new ServiceRegistration($appId, $class); |
||
| 374 | } |
||
| 375 | |||
| 376 | public function registerSearchProvider(string $appId, string $class) { |
||
| 377 | $this->searchProviders[] = new ServiceRegistration($appId, $class); |
||
| 378 | } |
||
| 379 | |||
| 380 | public function registerAlternativeLogin(string $appId, string $class): void { |
||
| 381 | $this->alternativeLogins[] = new ServiceRegistration($appId, $class); |
||
| 382 | } |
||
| 383 | |||
| 384 | public function registerInitialState(string $appId, string $class): void { |
||
| 385 | $this->initialStates[] = new ServiceRegistration($appId, $class); |
||
| 386 | } |
||
| 387 | |||
| 388 | public function registerWellKnown(string $appId, string $class): void { |
||
| 389 | $this->wellKnownHandlers[] = new ServiceRegistration($appId, $class); |
||
| 390 | } |
||
| 391 | |||
| 392 | public function registerTemplateProvider(string $appId, string $class): void { |
||
| 393 | $this->templateProviders[] = new ServiceRegistration($appId, $class); |
||
| 394 | } |
||
| 395 | |||
| 396 | public function registerNotifierService(string $appId, string $class): void { |
||
| 397 | $this->notifierServices[] = new ServiceRegistration($appId, $class); |
||
| 398 | } |
||
| 399 | |||
| 400 | public function registerTwoFactorProvider(string $appId, string $class): void { |
||
| 401 | $this->twoFactorProviders[] = new ServiceRegistration($appId, $class); |
||
| 402 | } |
||
| 403 | |||
| 404 | public function registerPreviewProvider(string $appId, string $class, string $mimeTypeRegex): void { |
||
| 405 | $this->previewProviders[] = new PreviewProviderRegistration($appId, $class, $mimeTypeRegex); |
||
| 406 | } |
||
| 407 | |||
| 408 | public function registerCalendarProvider(string $appId, string $class): void { |
||
| 409 | $this->calendarProviders[] = new ServiceRegistration($appId, $class); |
||
| 410 | } |
||
| 411 | |||
| 412 | public function registerReferenceProvider(string $appId, string $class): void { |
||
| 413 | $this->referenceProviders[] = new ServiceRegistration($appId, $class); |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @psalm-param class-string<ILinkAction> $actionClass |
||
| 418 | */ |
||
| 419 | public function registerProfileLinkAction(string $appId, string $actionClass): void { |
||
| 420 | $this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass); |
||
| 421 | } |
||
| 422 | |||
| 423 | /** |
||
| 424 | * @psalm-param class-string<ITalkBackend> $backend |
||
| 425 | */ |
||
| 426 | public function registerTalkBackend(string $appId, string $backend) { |
||
| 436 | } |
||
| 437 | |||
| 438 | public function registerCalendarResourceBackend(string $appId, string $class) { |
||
| 439 | $this->calendarResourceBackendRegistrations[] = new ServiceRegistration( |
||
| 440 | $appId, |
||
| 441 | $class, |
||
| 442 | ); |
||
| 443 | } |
||
| 444 | |||
| 445 | public function registerCalendarRoomBackend(string $appId, string $class) { |
||
| 446 | $this->calendarRoomBackendRegistrations[] = new ServiceRegistration( |
||
| 447 | $appId, |
||
| 448 | $class, |
||
| 449 | ); |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @psalm-param class-string<IUserMigrator> $migratorClass |
||
| 454 | */ |
||
| 455 | public function registerUserMigrator(string $appId, string $migratorClass): void { |
||
| 456 | $this->userMigrators[] = new ServiceRegistration($appId, $migratorClass); |
||
| 457 | } |
||
| 458 | |||
| 459 | public function registerSensitiveMethods(string $appId, string $class, array $methods): void { |
||
| 460 | $methods = array_filter($methods, 'is_string'); |
||
| 461 | $this->sensitiveMethods[] = new ParameterRegistration($appId, $class, $methods); |
||
| 462 | } |
||
| 463 | |||
| 464 | /** |
||
| 465 | * @param App[] $apps |
||
| 466 | */ |
||
| 467 | public function delegateCapabilityRegistrations(array $apps): void { |
||
| 468 | while (($registration = array_shift($this->capabilities)) !== null) { |
||
|
|
|||
| 469 | $appId = $registration->getAppId(); |
||
| 470 | if (!isset($apps[$appId])) { |
||
| 471 | // If we land here something really isn't right. But at least we caught the |
||
| 472 | // notice that is otherwise emitted for the undefined index |
||
| 473 | $this->logger->error("App $appId not loaded for the capability registration"); |
||
| 474 | |||
| 475 | continue; |
||
| 476 | } |
||
| 477 | |||
| 478 | try { |
||
| 479 | $apps[$appId] |
||
| 480 | ->getContainer() |
||
| 481 | ->registerCapability($registration->getService()); |
||
| 482 | } catch (Throwable $e) { |
||
| 483 | $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [ |
||
| 484 | 'exception' => $e, |
||
| 485 | ]); |
||
| 486 | } |
||
| 487 | } |
||
| 488 | } |
||
| 489 | |||
| 490 | /** |
||
| 491 | * @param App[] $apps |
||
| 492 | */ |
||
| 493 | public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void { |
||
| 494 | while (($registration = array_shift($this->crashReporters)) !== null) { |
||
| 495 | try { |
||
| 496 | $registry->registerLazy($registration->getService()); |
||
| 497 | } catch (Throwable $e) { |
||
| 498 | $appId = $registration->getAppId(); |
||
| 499 | $this->logger->error("Error during crash reporter registration of $appId: " . $e->getMessage(), [ |
||
| 500 | 'exception' => $e, |
||
| 501 | ]); |
||
| 502 | } |
||
| 503 | } |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * @param App[] $apps |
||
| 508 | */ |
||
| 509 | public function delegateDashboardPanelRegistrations(IManager $dashboardManager): void { |
||
| 510 | while (($panel = array_shift($this->dashboardPanels)) !== null) { |
||
| 511 | try { |
||
| 512 | $dashboardManager->lazyRegisterWidget($panel->getService(), $panel->getAppId()); |
||
| 513 | } catch (Throwable $e) { |
||
| 514 | $appId = $panel->getAppId(); |
||
| 515 | $this->logger->error("Error during dashboard registration of $appId: " . $e->getMessage(), [ |
||
| 516 | 'exception' => $e, |
||
| 517 | ]); |
||
| 518 | } |
||
| 519 | } |
||
| 520 | } |
||
| 521 | |||
| 522 | public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void { |
||
| 523 | while (($registration = array_shift($this->eventListeners)) !== null) { |
||
| 524 | try { |
||
| 525 | $eventDispatcher->addServiceListener( |
||
| 526 | $registration->getEvent(), |
||
| 527 | $registration->getService(), |
||
| 528 | $registration->getPriority() |
||
| 529 | ); |
||
| 530 | } catch (Throwable $e) { |
||
| 531 | $appId = $registration->getAppId(); |
||
| 532 | $this->logger->error("Error during event listener registration of $appId: " . $e->getMessage(), [ |
||
| 533 | 'exception' => $e, |
||
| 534 | ]); |
||
| 535 | } |
||
| 536 | } |
||
| 537 | } |
||
| 538 | |||
| 539 | /** |
||
| 540 | * @param App[] $apps |
||
| 541 | */ |
||
| 542 | public function delegateContainerRegistrations(array $apps): void { |
||
| 543 | while (($registration = array_shift($this->services)) !== null) { |
||
| 544 | $appId = $registration->getAppId(); |
||
| 545 | if (!isset($apps[$appId])) { |
||
| 546 | // If we land here something really isn't right. But at least we caught the |
||
| 547 | // notice that is otherwise emitted for the undefined index |
||
| 548 | $this->logger->error("App $appId not loaded for the container service registration"); |
||
| 549 | |||
| 550 | continue; |
||
| 551 | } |
||
| 552 | |||
| 553 | try { |
||
| 554 | /** |
||
| 555 | * Register the service and convert the callable into a \Closure if necessary |
||
| 556 | */ |
||
| 557 | $apps[$appId] |
||
| 558 | ->getContainer() |
||
| 559 | ->registerService( |
||
| 560 | $registration->getName(), |
||
| 561 | Closure::fromCallable($registration->getFactory()), |
||
| 562 | $registration->isShared() |
||
| 563 | ); |
||
| 564 | } catch (Throwable $e) { |
||
| 565 | $this->logger->error("Error during service registration of $appId: " . $e->getMessage(), [ |
||
| 566 | 'exception' => $e, |
||
| 567 | ]); |
||
| 568 | } |
||
| 569 | } |
||
| 570 | |||
| 571 | while (($registration = array_shift($this->aliases)) !== null) { |
||
| 572 | $appId = $registration->getAppId(); |
||
| 573 | if (!isset($apps[$appId])) { |
||
| 574 | // If we land here something really isn't right. But at least we caught the |
||
| 575 | // notice that is otherwise emitted for the undefined index |
||
| 576 | $this->logger->error("App $appId not loaded for the container alias registration"); |
||
| 577 | |||
| 578 | continue; |
||
| 579 | } |
||
| 580 | |||
| 581 | try { |
||
| 582 | $apps[$appId] |
||
| 583 | ->getContainer() |
||
| 584 | ->registerAlias( |
||
| 585 | $registration->getAlias(), |
||
| 586 | $registration->getTarget() |
||
| 587 | ); |
||
| 588 | } catch (Throwable $e) { |
||
| 589 | $this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [ |
||
| 590 | 'exception' => $e, |
||
| 591 | ]); |
||
| 592 | } |
||
| 593 | } |
||
| 594 | |||
| 595 | while (($registration = array_shift($this->parameters)) !== null) { |
||
| 596 | $appId = $registration->getAppId(); |
||
| 597 | if (!isset($apps[$appId])) { |
||
| 598 | // If we land here something really isn't right. But at least we caught the |
||
| 599 | // notice that is otherwise emitted for the undefined index |
||
| 600 | $this->logger->error("App $appId not loaded for the container parameter registration"); |
||
| 601 | |||
| 602 | continue; |
||
| 603 | } |
||
| 604 | |||
| 605 | try { |
||
| 606 | $apps[$appId] |
||
| 607 | ->getContainer() |
||
| 608 | ->registerParameter( |
||
| 609 | $registration->getName(), |
||
| 610 | $registration->getValue() |
||
| 611 | ); |
||
| 612 | } catch (Throwable $e) { |
||
| 613 | $this->logger->error("Error during service parameter registration of $appId: " . $e->getMessage(), [ |
||
| 614 | 'exception' => $e, |
||
| 615 | ]); |
||
| 616 | } |
||
| 617 | } |
||
| 618 | } |
||
| 619 | |||
| 620 | /** |
||
| 621 | * @param App[] $apps |
||
| 622 | */ |
||
| 623 | public function delegateMiddlewareRegistrations(array $apps): void { |
||
| 624 | while (($middleware = array_shift($this->middlewares)) !== null) { |
||
| 625 | $appId = $middleware->getAppId(); |
||
| 626 | if (!isset($apps[$appId])) { |
||
| 627 | // If we land here something really isn't right. But at least we caught the |
||
| 628 | // notice that is otherwise emitted for the undefined index |
||
| 629 | $this->logger->error("App $appId not loaded for the container middleware registration"); |
||
| 630 | |||
| 631 | continue; |
||
| 632 | } |
||
| 633 | |||
| 634 | try { |
||
| 635 | $apps[$appId] |
||
| 636 | ->getContainer() |
||
| 637 | ->registerMiddleWare($middleware->getService()); |
||
| 638 | } catch (Throwable $e) { |
||
| 639 | $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [ |
||
| 640 | 'exception' => $e, |
||
| 641 | ]); |
||
| 642 | } |
||
| 643 | } |
||
| 644 | } |
||
| 645 | |||
| 646 | /** |
||
| 647 | * @return ServiceRegistration<IProvider>[] |
||
| 648 | */ |
||
| 649 | public function getSearchProviders(): array { |
||
| 650 | return $this->searchProviders; |
||
| 651 | } |
||
| 652 | |||
| 653 | /** |
||
| 654 | * @return ServiceRegistration<IAlternativeLogin>[] |
||
| 655 | */ |
||
| 656 | public function getAlternativeLogins(): array { |
||
| 657 | return $this->alternativeLogins; |
||
| 658 | } |
||
| 659 | |||
| 660 | /** |
||
| 661 | * @return ServiceRegistration<InitialStateProvider>[] |
||
| 662 | */ |
||
| 663 | public function getInitialStates(): array { |
||
| 664 | return $this->initialStates; |
||
| 665 | } |
||
| 666 | |||
| 667 | /** |
||
| 668 | * @return ServiceRegistration<IHandler>[] |
||
| 669 | */ |
||
| 670 | public function getWellKnownHandlers(): array { |
||
| 672 | } |
||
| 673 | |||
| 674 | /** |
||
| 675 | * @return ServiceRegistration<ICustomTemplateProvider>[] |
||
| 676 | */ |
||
| 677 | public function getTemplateProviders(): array { |
||
| 678 | return $this->templateProviders; |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @return ServiceRegistration<INotifier>[] |
||
| 683 | */ |
||
| 684 | public function getNotifierServices(): array { |
||
| 685 | return $this->notifierServices; |
||
| 686 | } |
||
| 687 | |||
| 688 | /** |
||
| 689 | * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] |
||
| 690 | */ |
||
| 691 | public function getTwoFactorProviders(): array { |
||
| 692 | return $this->twoFactorProviders; |
||
| 693 | } |
||
| 694 | |||
| 695 | /** |
||
| 696 | * @return PreviewProviderRegistration[] |
||
| 697 | */ |
||
| 698 | public function getPreviewProviders(): array { |
||
| 699 | return $this->previewProviders; |
||
| 700 | } |
||
| 701 | |||
| 702 | /** |
||
| 703 | * @return ServiceRegistration<ICalendarProvider>[] |
||
| 704 | */ |
||
| 705 | public function getCalendarProviders(): array { |
||
| 706 | return $this->calendarProviders; |
||
| 707 | } |
||
| 708 | |||
| 709 | /** |
||
| 710 | * @return ServiceRegistration<IReferenceProvider>[] |
||
| 711 | */ |
||
| 712 | public function getReferenceProviders(): array { |
||
| 713 | return $this->referenceProviders; |
||
| 714 | } |
||
| 715 | |||
| 716 | /** |
||
| 717 | * @return ServiceRegistration<ILinkAction>[] |
||
| 718 | */ |
||
| 719 | public function getProfileLinkActions(): array { |
||
| 720 | return $this->profileLinkActions; |
||
| 721 | } |
||
| 722 | |||
| 723 | /** |
||
| 724 | * @return ServiceRegistration|null |
||
| 725 | * @psalm-return ServiceRegistration<ITalkBackend>|null |
||
| 726 | */ |
||
| 727 | public function getTalkBackendRegistration(): ?ServiceRegistration { |
||
| 728 | return $this->talkBackendRegistration; |
||
| 729 | } |
||
| 730 | |||
| 731 | /** |
||
| 732 | * @return ServiceRegistration[] |
||
| 733 | * @psalm-return ServiceRegistration<IResourceBackend>[] |
||
| 734 | */ |
||
| 735 | public function getCalendarResourceBackendRegistrations(): array { |
||
| 737 | } |
||
| 738 | |||
| 739 | /** |
||
| 740 | * @return ServiceRegistration[] |
||
| 741 | * @psalm-return ServiceRegistration<IRoomBackend>[] |
||
| 742 | */ |
||
| 743 | public function getCalendarRoomBackendRegistrations(): array { |
||
| 744 | return $this->calendarRoomBackendRegistrations; |
||
| 745 | } |
||
| 746 | |||
| 747 | /** |
||
| 748 | * @return ServiceRegistration<IUserMigrator>[] |
||
| 749 | */ |
||
| 750 | public function getUserMigrators(): array { |
||
| 752 | } |
||
| 753 | |||
| 754 | /** |
||
| 755 | * @return ParameterRegistration[] |
||
| 756 | */ |
||
| 757 | public function getSensitiveMethods(): array { |
||
| 758 | return $this->sensitiveMethods; |
||
| 759 | } |
||
| 760 | } |
||
| 761 |