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