RegistrationContext.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OC\AppFramework\Bootstrap;
  28. use Closure;
  29. use OC\Support\CrashReport\Registry;
  30. use OCP\AppFramework\App;
  31. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  32. use OCP\AppFramework\Middleware;
  33. use OCP\AppFramework\Services\InitialStateProvider;
  34. use OCP\Authentication\IAlternativeLogin;
  35. use OCP\Calendar\ICalendarProvider;
  36. use OCP\Calendar\Resource\IBackend as IResourceBackend;
  37. use OCP\Calendar\Room\IBackend as IRoomBackend;
  38. use OCP\Capabilities\ICapability;
  39. use OCP\Collaboration\Reference\IReferenceProvider;
  40. use OCP\Dashboard\IManager;
  41. use OCP\Dashboard\IWidget;
  42. use OCP\EventDispatcher\IEventDispatcher;
  43. use OCP\Files\Template\ICustomTemplateProvider;
  44. use OCP\Http\WellKnown\IHandler;
  45. use OCP\Notification\INotifier;
  46. use OCP\Profile\ILinkAction;
  47. use OCP\Search\IProvider;
  48. use OCP\SetupCheck\ISetupCheck;
  49. use OCP\Share\IPublicShareTemplateProvider;
  50. use OCP\SpeechToText\ISpeechToTextProvider;
  51. use OCP\Support\CrashReport\IReporter;
  52. use OCP\Talk\ITalkBackend;
  53. use OCP\TextProcessing\IProvider as ITextProcessingProvider;
  54. use OCP\Translation\ITranslationProvider;
  55. use OCP\UserMigration\IMigrator as IUserMigrator;
  56. use Psr\Log\LoggerInterface;
  57. use RuntimeException;
  58. use Throwable;
  59. use function array_shift;
  60. class RegistrationContext {
  61. /** @var ServiceRegistration<ICapability>[] */
  62. private $capabilities = [];
  63. /** @var ServiceRegistration<IReporter>[] */
  64. private $crashReporters = [];
  65. /** @var ServiceRegistration<IWidget>[] */
  66. private $dashboardPanels = [];
  67. /** @var ServiceRegistration<ILinkAction>[] */
  68. private $profileLinkActions = [];
  69. /** @var null|ServiceRegistration<ITalkBackend> */
  70. private $talkBackendRegistration = null;
  71. /** @var ServiceRegistration<IResourceBackend>[] */
  72. private $calendarResourceBackendRegistrations = [];
  73. /** @var ServiceRegistration<IRoomBackend>[] */
  74. private $calendarRoomBackendRegistrations = [];
  75. /** @var ServiceRegistration<IUserMigrator>[] */
  76. private $userMigrators = [];
  77. /** @var ServiceFactoryRegistration[] */
  78. private $services = [];
  79. /** @var ServiceAliasRegistration[] */
  80. private $aliases = [];
  81. /** @var ParameterRegistration[] */
  82. private $parameters = [];
  83. /** @var EventListenerRegistration[] */
  84. private $eventListeners = [];
  85. /** @var MiddlewareRegistration[] */
  86. private $middlewares = [];
  87. /** @var ServiceRegistration<IProvider>[] */
  88. private $searchProviders = [];
  89. /** @var ServiceRegistration<IAlternativeLogin>[] */
  90. private $alternativeLogins = [];
  91. /** @var ServiceRegistration<InitialStateProvider>[] */
  92. private $initialStates = [];
  93. /** @var ServiceRegistration<IHandler>[] */
  94. private $wellKnownHandlers = [];
  95. /** @var ServiceRegistration<ISpeechToTextProvider>[] */
  96. private $speechToTextProviders = [];
  97. /** @var ServiceRegistration<ITextProcessingProvider>[] */
  98. private $textProcessingProviders = [];
  99. /** @var ServiceRegistration<ICustomTemplateProvider>[] */
  100. private $templateProviders = [];
  101. /** @var ServiceRegistration<ITranslationProvider>[] */
  102. private $translationProviders = [];
  103. /** @var ServiceRegistration<INotifier>[] */
  104. private $notifierServices = [];
  105. /** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */
  106. private $twoFactorProviders = [];
  107. /** @var ServiceRegistration<ICalendarProvider>[] */
  108. private $calendarProviders = [];
  109. /** @var ServiceRegistration<IReferenceProvider>[] */
  110. private array $referenceProviders = [];
  111. /** @var ServiceRegistration<\OCP\TextToImage\IProvider>[] */
  112. private $textToImageProviders = [];
  113. /** @var ParameterRegistration[] */
  114. private $sensitiveMethods = [];
  115. /** @var ServiceRegistration<IPublicShareTemplateProvider>[] */
  116. private $publicShareTemplateProviders = [];
  117. private LoggerInterface $logger;
  118. /** @var ServiceRegistration<ISetupCheck>[] */
  119. private array $setupChecks = [];
  120. /** @var PreviewProviderRegistration[] */
  121. private array $previewProviders = [];
  122. public function __construct(LoggerInterface $logger) {
  123. $this->logger = $logger;
  124. }
  125. public function for(string $appId): IRegistrationContext {
  126. return new class($appId, $this) implements IRegistrationContext {
  127. /** @var string */
  128. private $appId;
  129. /** @var RegistrationContext */
  130. private $context;
  131. public function __construct(string $appId, RegistrationContext $context) {
  132. $this->appId = $appId;
  133. $this->context = $context;
  134. }
  135. public function registerCapability(string $capability): void {
  136. $this->context->registerCapability(
  137. $this->appId,
  138. $capability
  139. );
  140. }
  141. public function registerCrashReporter(string $reporterClass): void {
  142. $this->context->registerCrashReporter(
  143. $this->appId,
  144. $reporterClass
  145. );
  146. }
  147. public function registerDashboardWidget(string $widgetClass): void {
  148. $this->context->registerDashboardPanel(
  149. $this->appId,
  150. $widgetClass
  151. );
  152. }
  153. public function registerService(string $name, callable $factory, bool $shared = true): void {
  154. $this->context->registerService(
  155. $this->appId,
  156. $name,
  157. $factory,
  158. $shared
  159. );
  160. }
  161. public function registerServiceAlias(string $alias, string $target): void {
  162. $this->context->registerServiceAlias(
  163. $this->appId,
  164. $alias,
  165. $target
  166. );
  167. }
  168. public function registerParameter(string $name, $value): void {
  169. $this->context->registerParameter(
  170. $this->appId,
  171. $name,
  172. $value
  173. );
  174. }
  175. public function registerEventListener(string $event, string $listener, int $priority = 0): void {
  176. $this->context->registerEventListener(
  177. $this->appId,
  178. $event,
  179. $listener,
  180. $priority
  181. );
  182. }
  183. public function registerMiddleware(string $class, bool $global = false): void {
  184. $this->context->registerMiddleware(
  185. $this->appId,
  186. $class,
  187. $global,
  188. );
  189. }
  190. public function registerSearchProvider(string $class): void {
  191. $this->context->registerSearchProvider(
  192. $this->appId,
  193. $class
  194. );
  195. }
  196. public function registerAlternativeLogin(string $class): void {
  197. $this->context->registerAlternativeLogin(
  198. $this->appId,
  199. $class
  200. );
  201. }
  202. public function registerInitialStateProvider(string $class): void {
  203. $this->context->registerInitialState(
  204. $this->appId,
  205. $class
  206. );
  207. }
  208. public function registerWellKnownHandler(string $class): void {
  209. $this->context->registerWellKnown(
  210. $this->appId,
  211. $class
  212. );
  213. }
  214. public function registerSpeechToTextProvider(string $providerClass): void {
  215. $this->context->registerSpeechToTextProvider(
  216. $this->appId,
  217. $providerClass
  218. );
  219. }
  220. public function registerTextProcessingProvider(string $providerClass): void {
  221. $this->context->registerTextProcessingProvider(
  222. $this->appId,
  223. $providerClass
  224. );
  225. }
  226. public function registerTextToImageProvider(string $providerClass): void {
  227. $this->context->registerTextToImageProvider(
  228. $this->appId,
  229. $providerClass
  230. );
  231. }
  232. public function registerTemplateProvider(string $providerClass): void {
  233. $this->context->registerTemplateProvider(
  234. $this->appId,
  235. $providerClass
  236. );
  237. }
  238. public function registerTranslationProvider(string $providerClass): void {
  239. $this->context->registerTranslationProvider(
  240. $this->appId,
  241. $providerClass
  242. );
  243. }
  244. public function registerNotifierService(string $notifierClass): void {
  245. $this->context->registerNotifierService(
  246. $this->appId,
  247. $notifierClass
  248. );
  249. }
  250. public function registerTwoFactorProvider(string $twoFactorProviderClass): void {
  251. $this->context->registerTwoFactorProvider(
  252. $this->appId,
  253. $twoFactorProviderClass
  254. );
  255. }
  256. public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void {
  257. $this->context->registerPreviewProvider(
  258. $this->appId,
  259. $previewProviderClass,
  260. $mimeTypeRegex
  261. );
  262. }
  263. public function registerCalendarProvider(string $class): void {
  264. $this->context->registerCalendarProvider(
  265. $this->appId,
  266. $class
  267. );
  268. }
  269. public function registerReferenceProvider(string $class): void {
  270. $this->context->registerReferenceProvider(
  271. $this->appId,
  272. $class
  273. );
  274. }
  275. public function registerProfileLinkAction(string $actionClass): void {
  276. $this->context->registerProfileLinkAction(
  277. $this->appId,
  278. $actionClass
  279. );
  280. }
  281. public function registerTalkBackend(string $backend): void {
  282. $this->context->registerTalkBackend(
  283. $this->appId,
  284. $backend
  285. );
  286. }
  287. public function registerCalendarResourceBackend(string $class): void {
  288. $this->context->registerCalendarResourceBackend(
  289. $this->appId,
  290. $class
  291. );
  292. }
  293. public function registerCalendarRoomBackend(string $class): void {
  294. $this->context->registerCalendarRoomBackend(
  295. $this->appId,
  296. $class
  297. );
  298. }
  299. public function registerUserMigrator(string $migratorClass): void {
  300. $this->context->registerUserMigrator(
  301. $this->appId,
  302. $migratorClass
  303. );
  304. }
  305. public function registerSensitiveMethods(string $class, array $methods): void {
  306. $this->context->registerSensitiveMethods(
  307. $this->appId,
  308. $class,
  309. $methods
  310. );
  311. }
  312. public function registerPublicShareTemplateProvider(string $class): void {
  313. $this->context->registerPublicShareTemplateProvider(
  314. $this->appId,
  315. $class
  316. );
  317. }
  318. public function registerSetupCheck(string $setupCheckClass): void {
  319. $this->context->registerSetupCheck(
  320. $this->appId,
  321. $setupCheckClass
  322. );
  323. }
  324. };
  325. }
  326. /**
  327. * @psalm-param class-string<ICapability> $capability
  328. */
  329. public function registerCapability(string $appId, string $capability): void {
  330. $this->capabilities[] = new ServiceRegistration($appId, $capability);
  331. }
  332. /**
  333. * @psalm-param class-string<IReporter> $reporterClass
  334. */
  335. public function registerCrashReporter(string $appId, string $reporterClass): void {
  336. $this->crashReporters[] = new ServiceRegistration($appId, $reporterClass);
  337. }
  338. /**
  339. * @psalm-param class-string<IWidget> $panelClass
  340. */
  341. public function registerDashboardPanel(string $appId, string $panelClass): void {
  342. $this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass);
  343. }
  344. public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
  345. $this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared);
  346. }
  347. public function registerServiceAlias(string $appId, string $alias, string $target): void {
  348. $this->aliases[] = new ServiceAliasRegistration($appId, $alias, $target);
  349. }
  350. public function registerParameter(string $appId, string $name, $value): void {
  351. $this->parameters[] = new ParameterRegistration($appId, $name, $value);
  352. }
  353. public function registerEventListener(string $appId, string $event, string $listener, int $priority = 0): void {
  354. $this->eventListeners[] = new EventListenerRegistration($appId, $event, $listener, $priority);
  355. }
  356. /**
  357. * @psalm-param class-string<Middleware> $class
  358. */
  359. public function registerMiddleware(string $appId, string $class, bool $global): void {
  360. $this->middlewares[] = new MiddlewareRegistration($appId, $class, $global);
  361. }
  362. public function registerSearchProvider(string $appId, string $class) {
  363. $this->searchProviders[] = new ServiceRegistration($appId, $class);
  364. }
  365. public function registerAlternativeLogin(string $appId, string $class): void {
  366. $this->alternativeLogins[] = new ServiceRegistration($appId, $class);
  367. }
  368. public function registerInitialState(string $appId, string $class): void {
  369. $this->initialStates[] = new ServiceRegistration($appId, $class);
  370. }
  371. public function registerWellKnown(string $appId, string $class): void {
  372. $this->wellKnownHandlers[] = new ServiceRegistration($appId, $class);
  373. }
  374. public function registerSpeechToTextProvider(string $appId, string $class): void {
  375. $this->speechToTextProviders[] = new ServiceRegistration($appId, $class);
  376. }
  377. public function registerTextProcessingProvider(string $appId, string $class): void {
  378. $this->textProcessingProviders[] = new ServiceRegistration($appId, $class);
  379. }
  380. public function registerTextToImageProvider(string $appId, string $class): void {
  381. $this->textToImageProviders[] = new ServiceRegistration($appId, $class);
  382. }
  383. public function registerTemplateProvider(string $appId, string $class): void {
  384. $this->templateProviders[] = new ServiceRegistration($appId, $class);
  385. }
  386. public function registerTranslationProvider(string $appId, string $class): void {
  387. $this->translationProviders[] = new ServiceRegistration($appId, $class);
  388. }
  389. public function registerNotifierService(string $appId, string $class): void {
  390. $this->notifierServices[] = new ServiceRegistration($appId, $class);
  391. }
  392. public function registerTwoFactorProvider(string $appId, string $class): void {
  393. $this->twoFactorProviders[] = new ServiceRegistration($appId, $class);
  394. }
  395. public function registerPreviewProvider(string $appId, string $class, string $mimeTypeRegex): void {
  396. $this->previewProviders[] = new PreviewProviderRegistration($appId, $class, $mimeTypeRegex);
  397. }
  398. public function registerCalendarProvider(string $appId, string $class): void {
  399. $this->calendarProviders[] = new ServiceRegistration($appId, $class);
  400. }
  401. public function registerReferenceProvider(string $appId, string $class): void {
  402. $this->referenceProviders[] = new ServiceRegistration($appId, $class);
  403. }
  404. /**
  405. * @psalm-param class-string<ILinkAction> $actionClass
  406. */
  407. public function registerProfileLinkAction(string $appId, string $actionClass): void {
  408. $this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass);
  409. }
  410. /**
  411. * @psalm-param class-string<ITalkBackend> $backend
  412. */
  413. public function registerTalkBackend(string $appId, string $backend) {
  414. // Some safeguards for invalid registrations
  415. if ($appId !== 'spreed') {
  416. throw new RuntimeException("Only the Talk app is allowed to register a Talk backend");
  417. }
  418. if ($this->talkBackendRegistration !== null) {
  419. throw new RuntimeException("There can only be one Talk backend");
  420. }
  421. $this->talkBackendRegistration = new ServiceRegistration($appId, $backend);
  422. }
  423. public function registerCalendarResourceBackend(string $appId, string $class) {
  424. $this->calendarResourceBackendRegistrations[] = new ServiceRegistration(
  425. $appId,
  426. $class,
  427. );
  428. }
  429. public function registerCalendarRoomBackend(string $appId, string $class) {
  430. $this->calendarRoomBackendRegistrations[] = new ServiceRegistration(
  431. $appId,
  432. $class,
  433. );
  434. }
  435. /**
  436. * @psalm-param class-string<IUserMigrator> $migratorClass
  437. */
  438. public function registerUserMigrator(string $appId, string $migratorClass): void {
  439. $this->userMigrators[] = new ServiceRegistration($appId, $migratorClass);
  440. }
  441. public function registerSensitiveMethods(string $appId, string $class, array $methods): void {
  442. $methods = array_filter($methods, 'is_string');
  443. $this->sensitiveMethods[] = new ParameterRegistration($appId, $class, $methods);
  444. }
  445. public function registerPublicShareTemplateProvider(string $appId, string $class): void {
  446. $this->publicShareTemplateProviders[] = new ServiceRegistration($appId, $class);
  447. }
  448. /**
  449. * @psalm-param class-string<ISetupCheck> $setupCheckClass
  450. */
  451. public function registerSetupCheck(string $appId, string $setupCheckClass): void {
  452. $this->setupChecks[] = new ServiceRegistration($appId, $setupCheckClass);
  453. }
  454. /**
  455. * @param App[] $apps
  456. */
  457. public function delegateCapabilityRegistrations(array $apps): void {
  458. while (($registration = array_shift($this->capabilities)) !== null) {
  459. $appId = $registration->getAppId();
  460. if (!isset($apps[$appId])) {
  461. // If we land here something really isn't right. But at least we caught the
  462. // notice that is otherwise emitted for the undefined index
  463. $this->logger->error("App $appId not loaded for the capability registration");
  464. continue;
  465. }
  466. try {
  467. $apps[$appId]
  468. ->getContainer()
  469. ->registerCapability($registration->getService());
  470. } catch (Throwable $e) {
  471. $this->logger->error("Error during capability registration of $appId: " . $e->getMessage(), [
  472. 'exception' => $e,
  473. ]);
  474. }
  475. }
  476. }
  477. /**
  478. * @param App[] $apps
  479. */
  480. public function delegateCrashReporterRegistrations(array $apps, Registry $registry): void {
  481. while (($registration = array_shift($this->crashReporters)) !== null) {
  482. try {
  483. $registry->registerLazy($registration->getService());
  484. } catch (Throwable $e) {
  485. $appId = $registration->getAppId();
  486. $this->logger->error("Error during crash reporter registration of $appId: " . $e->getMessage(), [
  487. 'exception' => $e,
  488. ]);
  489. }
  490. }
  491. }
  492. public function delegateDashboardPanelRegistrations(IManager $dashboardManager): void {
  493. while (($panel = array_shift($this->dashboardPanels)) !== null) {
  494. try {
  495. $dashboardManager->lazyRegisterWidget($panel->getService(), $panel->getAppId());
  496. } catch (Throwable $e) {
  497. $appId = $panel->getAppId();
  498. $this->logger->error("Error during dashboard registration of $appId: " . $e->getMessage(), [
  499. 'exception' => $e,
  500. ]);
  501. }
  502. }
  503. }
  504. public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
  505. while (($registration = array_shift($this->eventListeners)) !== null) {
  506. try {
  507. $eventDispatcher->addServiceListener(
  508. $registration->getEvent(),
  509. $registration->getService(),
  510. $registration->getPriority()
  511. );
  512. } catch (Throwable $e) {
  513. $appId = $registration->getAppId();
  514. $this->logger->error("Error during event listener registration of $appId: " . $e->getMessage(), [
  515. 'exception' => $e,
  516. ]);
  517. }
  518. }
  519. }
  520. /**
  521. * @param App[] $apps
  522. */
  523. public function delegateContainerRegistrations(array $apps): void {
  524. while (($registration = array_shift($this->services)) !== null) {
  525. $appId = $registration->getAppId();
  526. if (!isset($apps[$appId])) {
  527. // If we land here something really isn't right. But at least we caught the
  528. // notice that is otherwise emitted for the undefined index
  529. $this->logger->error("App $appId not loaded for the container service registration");
  530. continue;
  531. }
  532. try {
  533. /**
  534. * Register the service and convert the callable into a \Closure if necessary
  535. */
  536. $apps[$appId]
  537. ->getContainer()
  538. ->registerService(
  539. $registration->getName(),
  540. Closure::fromCallable($registration->getFactory()),
  541. $registration->isShared()
  542. );
  543. } catch (Throwable $e) {
  544. $this->logger->error("Error during service registration of $appId: " . $e->getMessage(), [
  545. 'exception' => $e,
  546. ]);
  547. }
  548. }
  549. while (($registration = array_shift($this->aliases)) !== null) {
  550. $appId = $registration->getAppId();
  551. if (!isset($apps[$appId])) {
  552. // If we land here something really isn't right. But at least we caught the
  553. // notice that is otherwise emitted for the undefined index
  554. $this->logger->error("App $appId not loaded for the container alias registration");
  555. continue;
  556. }
  557. try {
  558. $apps[$appId]
  559. ->getContainer()
  560. ->registerAlias(
  561. $registration->getAlias(),
  562. $registration->getTarget()
  563. );
  564. } catch (Throwable $e) {
  565. $this->logger->error("Error during service alias registration of $appId: " . $e->getMessage(), [
  566. 'exception' => $e,
  567. ]);
  568. }
  569. }
  570. while (($registration = array_shift($this->parameters)) !== null) {
  571. $appId = $registration->getAppId();
  572. if (!isset($apps[$appId])) {
  573. // If we land here something really isn't right. But at least we caught the
  574. // notice that is otherwise emitted for the undefined index
  575. $this->logger->error("App $appId not loaded for the container parameter registration");
  576. continue;
  577. }
  578. try {
  579. $apps[$appId]
  580. ->getContainer()
  581. ->registerParameter(
  582. $registration->getName(),
  583. $registration->getValue()
  584. );
  585. } catch (Throwable $e) {
  586. $this->logger->error("Error during service parameter registration of $appId: " . $e->getMessage(), [
  587. 'exception' => $e,
  588. ]);
  589. }
  590. }
  591. }
  592. /**
  593. * @return MiddlewareRegistration[]
  594. */
  595. public function getMiddlewareRegistrations(): array {
  596. return $this->middlewares;
  597. }
  598. /**
  599. * @return ServiceRegistration<IProvider>[]
  600. */
  601. public function getSearchProviders(): array {
  602. return $this->searchProviders;
  603. }
  604. /**
  605. * @return ServiceRegistration<IAlternativeLogin>[]
  606. */
  607. public function getAlternativeLogins(): array {
  608. return $this->alternativeLogins;
  609. }
  610. /**
  611. * @return ServiceRegistration<InitialStateProvider>[]
  612. */
  613. public function getInitialStates(): array {
  614. return $this->initialStates;
  615. }
  616. /**
  617. * @return ServiceRegistration<IHandler>[]
  618. */
  619. public function getWellKnownHandlers(): array {
  620. return $this->wellKnownHandlers;
  621. }
  622. /**
  623. * @return ServiceRegistration<ISpeechToTextProvider>[]
  624. */
  625. public function getSpeechToTextProviders(): array {
  626. return $this->speechToTextProviders;
  627. }
  628. /**
  629. * @return ServiceRegistration<ITextProcessingProvider>[]
  630. */
  631. public function getTextProcessingProviders(): array {
  632. return $this->textProcessingProviders;
  633. }
  634. /**
  635. * @return ServiceRegistration<\OCP\TextToImage\IProvider>[]
  636. */
  637. public function getTextToImageProviders(): array {
  638. return $this->textToImageProviders;
  639. }
  640. /**
  641. * @return ServiceRegistration<ICustomTemplateProvider>[]
  642. */
  643. public function getTemplateProviders(): array {
  644. return $this->templateProviders;
  645. }
  646. /**
  647. * @return ServiceRegistration<ITranslationProvider>[]
  648. */
  649. public function getTranslationProviders(): array {
  650. return $this->translationProviders;
  651. }
  652. /**
  653. * @return ServiceRegistration<INotifier>[]
  654. */
  655. public function getNotifierServices(): array {
  656. return $this->notifierServices;
  657. }
  658. /**
  659. * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[]
  660. */
  661. public function getTwoFactorProviders(): array {
  662. return $this->twoFactorProviders;
  663. }
  664. /**
  665. * @return PreviewProviderRegistration[]
  666. */
  667. public function getPreviewProviders(): array {
  668. return $this->previewProviders;
  669. }
  670. /**
  671. * @return ServiceRegistration<ICalendarProvider>[]
  672. */
  673. public function getCalendarProviders(): array {
  674. return $this->calendarProviders;
  675. }
  676. /**
  677. * @return ServiceRegistration<IReferenceProvider>[]
  678. */
  679. public function getReferenceProviders(): array {
  680. return $this->referenceProviders;
  681. }
  682. /**
  683. * @return ServiceRegistration<ILinkAction>[]
  684. */
  685. public function getProfileLinkActions(): array {
  686. return $this->profileLinkActions;
  687. }
  688. /**
  689. * @return ServiceRegistration|null
  690. * @psalm-return ServiceRegistration<ITalkBackend>|null
  691. */
  692. public function getTalkBackendRegistration(): ?ServiceRegistration {
  693. return $this->talkBackendRegistration;
  694. }
  695. /**
  696. * @return ServiceRegistration[]
  697. * @psalm-return ServiceRegistration<IResourceBackend>[]
  698. */
  699. public function getCalendarResourceBackendRegistrations(): array {
  700. return $this->calendarResourceBackendRegistrations;
  701. }
  702. /**
  703. * @return ServiceRegistration[]
  704. * @psalm-return ServiceRegistration<IRoomBackend>[]
  705. */
  706. public function getCalendarRoomBackendRegistrations(): array {
  707. return $this->calendarRoomBackendRegistrations;
  708. }
  709. /**
  710. * @return ServiceRegistration<IUserMigrator>[]
  711. */
  712. public function getUserMigrators(): array {
  713. return $this->userMigrators;
  714. }
  715. /**
  716. * @return ParameterRegistration[]
  717. */
  718. public function getSensitiveMethods(): array {
  719. return $this->sensitiveMethods;
  720. }
  721. /**
  722. * @return ServiceRegistration<IPublicShareTemplateProvider>[]
  723. */
  724. public function getPublicShareTemplateProviders(): array {
  725. return $this->publicShareTemplateProviders;
  726. }
  727. /**
  728. * @return ServiceRegistration<ISetupCheck>[]
  729. */
  730. public function getSetupChecks(): array {
  731. return $this->setupChecks;
  732. }
  733. }