You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RegistrationContext.php 25KB

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