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