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