IRegistrationContext.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\AppFramework\Bootstrap;
  8. use OCP\AppFramework\IAppContainer;
  9. use OCP\Authentication\TwoFactorAuth\IProvider;
  10. use OCP\Calendar\ICalendarProvider;
  11. use OCP\Capabilities\ICapability;
  12. use OCP\Collaboration\Reference\IReferenceProvider;
  13. use OCP\EventDispatcher\IEventDispatcher;
  14. use OCP\Files\Template\ICustomTemplateProvider;
  15. use OCP\IContainer;
  16. use OCP\Mail\Provider\IProvider as IMailProvider;
  17. use OCP\Notification\INotifier;
  18. use OCP\Preview\IProviderV2;
  19. use OCP\SpeechToText\ISpeechToTextProvider;
  20. use OCP\TextProcessing\IProvider as ITextProcessingProvider;
  21. use OCP\TextToImage\IProvider as ITextToImageProvider;
  22. use OCP\Translation\ITranslationProvider;
  23. /**
  24. * The context object passed to IBootstrap::register
  25. *
  26. * @since 20.0.0
  27. * @see IBootstrap::register()
  28. */
  29. interface IRegistrationContext {
  30. /**
  31. * @param string $capability
  32. * @psalm-param class-string<ICapability> $capability
  33. * @see IAppContainer::registerCapability
  34. *
  35. * @since 20.0.0
  36. */
  37. public function registerCapability(string $capability): void;
  38. /**
  39. * Register an implementation of \OCP\Support\CrashReport\IReporter that
  40. * will receive unhandled exceptions and throwables
  41. *
  42. * @param string $reporterClass
  43. * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
  44. * @return void
  45. * @since 20.0.0
  46. */
  47. public function registerCrashReporter(string $reporterClass): void;
  48. /**
  49. * Register an implementation of \OCP\Dashboard\IWidget that
  50. * will handle the implementation of a dashboard widget
  51. *
  52. * @param string $widgetClass
  53. * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
  54. * @return void
  55. * @since 20.0.0
  56. */
  57. public function registerDashboardWidget(string $widgetClass): void;
  58. /**
  59. * Register a service
  60. *
  61. * @param string $name
  62. * @param callable $factory
  63. * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
  64. * @param bool $shared
  65. *
  66. * @return void
  67. * @see IContainer::registerService()
  68. *
  69. * @since 20.0.0
  70. */
  71. public function registerService(string $name, callable $factory, bool $shared = true): void;
  72. /**
  73. * @param string $alias
  74. * @psalm-param string|class-string $alias
  75. * @param string $target
  76. * @psalm-param string|class-string $target
  77. *
  78. * @return void
  79. * @see IContainer::registerAlias()
  80. *
  81. * @since 20.0.0
  82. */
  83. public function registerServiceAlias(string $alias, string $target): void;
  84. /**
  85. * @param string $name
  86. * @param mixed $value
  87. *
  88. * @return void
  89. * @see IContainer::registerParameter()
  90. *
  91. * @since 20.0.0
  92. */
  93. public function registerParameter(string $name, $value): void;
  94. /**
  95. * Register a service listener
  96. *
  97. * This is equivalent to calling IEventDispatcher::addServiceListener
  98. *
  99. * @psalm-template T of \OCP\EventDispatcher\Event
  100. * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
  101. * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
  102. * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
  103. * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $listener fully qualified class name that can be built by the DI container
  104. * @param int $priority The higher this value, the earlier an event
  105. * listener will be triggered in the chain (defaults to 0)
  106. *
  107. * @see IEventDispatcher::addServiceListener()
  108. *
  109. * @since 20.0.0
  110. */
  111. public function registerEventListener(string $event, string $listener, int $priority = 0): void;
  112. /**
  113. * @param string $class
  114. * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
  115. * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
  116. *
  117. * @return void
  118. * @see IAppContainer::registerMiddleWare()
  119. *
  120. * @since 20.0.0
  121. * @since 26.0.0 Added optional argument $global
  122. */
  123. public function registerMiddleware(string $class, bool $global = false): void;
  124. /**
  125. * Register a search provider for the unified search
  126. *
  127. * It is allowed to register more than one provider per app as the search
  128. * results can go into distinct sections, e.g. "Files" and "Files shared
  129. * with you" in the Files app.
  130. *
  131. * @param string $class
  132. * @psalm-param class-string<\OCP\Search\IProvider> $class
  133. *
  134. * @return void
  135. *
  136. * @since 20.0.0
  137. */
  138. public function registerSearchProvider(string $class): void;
  139. /**
  140. * Register an alternative login option
  141. *
  142. * It is allowed to register more than one option per app.
  143. *
  144. * @param string $class
  145. * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
  146. *
  147. * @return void
  148. *
  149. * @since 20.0.0
  150. */
  151. public function registerAlternativeLogin(string $class): void;
  152. /**
  153. * Register an initialstate provider
  154. *
  155. * It is allowed to register more than one provider per app.
  156. *
  157. * @param string $class
  158. * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
  159. *
  160. * @return void
  161. *
  162. * @since 21.0.0
  163. */
  164. public function registerInitialStateProvider(string $class): void;
  165. /**
  166. * Register a well known protocol handler
  167. *
  168. * It is allowed to register more than one handler per app.
  169. *
  170. * @param string $class
  171. * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
  172. *
  173. * @return void
  174. *
  175. * @since 21.0.0
  176. */
  177. public function registerWellKnownHandler(string $class): void;
  178. /**
  179. * Register a custom SpeechToText provider class that can provide transcription
  180. * of audio through the OCP\SpeechToText APIs
  181. *
  182. * @param string $providerClass
  183. * @psalm-param class-string<ISpeechToTextProvider> $providerClass
  184. * @since 27.0.0
  185. */
  186. public function registerSpeechToTextProvider(string $providerClass): void;
  187. /**
  188. * Register a custom text processing provider class that provides a promptable language model
  189. * through the OCP\TextProcessing APIs
  190. *
  191. * @param string $providerClass
  192. * @psalm-param class-string<ITextProcessingProvider> $providerClass
  193. * @since 27.1.0
  194. */
  195. public function registerTextProcessingProvider(string $providerClass): void;
  196. /**
  197. * Register a custom text2image provider class that provides the possibility to generate images
  198. * through the OCP\TextToImage APIs
  199. *
  200. * @param string $providerClass
  201. * @psalm-param class-string<ITextToImageProvider> $providerClass
  202. * @since 28.0.0
  203. */
  204. public function registerTextToImageProvider(string $providerClass): void;
  205. /**
  206. * Register a custom template provider class that is able to inject custom templates
  207. * in addition to the user defined ones
  208. *
  209. * @param string $providerClass
  210. * @psalm-param class-string<ICustomTemplateProvider> $providerClass
  211. * @since 21.0.0
  212. */
  213. public function registerTemplateProvider(string $providerClass): void;
  214. /**
  215. * Register a custom translation provider class that can provide translation
  216. * between languages through the OCP\Translation APIs
  217. *
  218. * @param string $providerClass
  219. * @psalm-param class-string<ITranslationProvider> $providerClass
  220. * @since 21.0.0
  221. */
  222. public function registerTranslationProvider(string $providerClass): void;
  223. /**
  224. * Register an INotifier class
  225. *
  226. * @param string $notifierClass
  227. * @psalm-param class-string<INotifier> $notifierClass
  228. * @since 22.0.0
  229. */
  230. public function registerNotifierService(string $notifierClass): void;
  231. /**
  232. * Register a two-factor provider
  233. *
  234. * @param string $twoFactorProviderClass
  235. * @psalm-param class-string<IProvider> $twoFactorProviderClass
  236. * @since 22.0.0
  237. */
  238. public function registerTwoFactorProvider(string $twoFactorProviderClass): void;
  239. /**
  240. * Register a preview provider
  241. *
  242. * It is allowed to register more than one provider per app.
  243. *
  244. * @param string $previewProviderClass
  245. * @param string $mimeTypeRegex
  246. * @psalm-param class-string<IProviderV2> $previewProviderClass
  247. * @since 23.0.0
  248. */
  249. public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void;
  250. /**
  251. * Register a calendar provider
  252. *
  253. * @param string $class
  254. * @psalm-param class-string<ICalendarProvider> $class
  255. * @since 23.0.0
  256. */
  257. public function registerCalendarProvider(string $class): void;
  258. /**
  259. * Register a reference provider
  260. *
  261. * @param string $class
  262. * @psalm-param class-string<IReferenceProvider> $class
  263. * @since 25.0.0
  264. */
  265. public function registerReferenceProvider(string $class): void;
  266. /**
  267. * Register an implementation of \OCP\Profile\ILinkAction that
  268. * will handle the implementation of a profile link action
  269. *
  270. * @param string $actionClass
  271. * @psalm-param class-string<\OCP\Profile\ILinkAction> $actionClass
  272. * @return void
  273. * @since 23.0.0
  274. */
  275. public function registerProfileLinkAction(string $actionClass): void;
  276. /**
  277. * Register the backend of the Talk app
  278. *
  279. * This service must only be used by the Talk app
  280. *
  281. * @param string $backend
  282. * @return void
  283. * @since 24.0.0
  284. */
  285. public function registerTalkBackend(string $backend): void;
  286. /**
  287. * Register a resource backend for the DAV server
  288. *
  289. * @param string $actionClass
  290. * @psalm-param class-string<\OCP\Calendar\Resource\IBackend> $actionClass
  291. * @return void
  292. * @since 24.0.0
  293. */
  294. public function registerCalendarResourceBackend(string $class): void;
  295. /**
  296. * Register a room backend for the DAV server
  297. *
  298. * @param string $actionClass
  299. * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
  300. * @return void
  301. * @since 24.0.0
  302. */
  303. public function registerCalendarRoomBackend(string $class): void;
  304. /**
  305. * @param string $class
  306. * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
  307. * @return void
  308. * @since 29.0.0
  309. */
  310. public function registerTeamResourceProvider(string $class): void;
  311. /**
  312. * Register an implementation of \OCP\UserMigration\IMigrator that
  313. * will handle the implementation of a migrator
  314. *
  315. * @param string $migratorClass
  316. * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
  317. * @return void
  318. * @since 24.0.0
  319. */
  320. public function registerUserMigrator(string $migratorClass): void;
  321. /**
  322. * Announce methods of classes that may contain sensitive values, which
  323. * should be obfuscated before being logged.
  324. *
  325. * @param string $class
  326. * @param string[] $methods
  327. * @return void
  328. * @since 25.0.0
  329. */
  330. public function registerSensitiveMethods(string $class, array $methods): void;
  331. /**
  332. * Register an implementation of IPublicShareTemplateProvider.
  333. *
  334. * @param string $class
  335. * @psalm-param class-string<\OCP\Share\IPublicShareTemplateProvider> $class
  336. * @return void
  337. * @since 26.0.0
  338. */
  339. public function registerPublicShareTemplateProvider(string $class): void;
  340. /**
  341. * Register an implementation of \OCP\SetupCheck\ISetupCheck that
  342. * will handle the implementation of a setup check
  343. *
  344. * @param class-string<\OCP\SetupCheck\ISetupCheck> $setupCheckClass
  345. * @since 28.0.0
  346. */
  347. public function registerSetupCheck(string $setupCheckClass): void;
  348. /**
  349. * Register an implementation of \OCP\Settings\IDeclarativeSettings that
  350. * will handle the implementation of declarative settings
  351. *
  352. * @param string $declarativeSettingsClass
  353. * @psalm-param class-string<\OCP\Settings\IDeclarativeSettingsForm> $declarativeSettingsClass
  354. * @return void
  355. * @since 29.0.0
  356. */
  357. public function registerDeclarativeSettings(string $declarativeSettingsClass): void;
  358. /**
  359. * Register an implementation of \OCP\TaskProcessing\IProvider that
  360. * will handle the implementation of task processing
  361. *
  362. * @param string $taskProcessingProviderClass
  363. * @psalm-param class-string<\OCP\TaskProcessing\IProvider> $taskProcessingProviderClass
  364. * @return void
  365. * @since 30.0.0
  366. */
  367. public function registerTaskProcessingProvider(string $taskProcessingProviderClass): void;
  368. /**
  369. * Register an implementation of \OCP\TaskProcessing\ITaskType that
  370. * will handle the implementation of a task processing type
  371. *
  372. * @param string $taskProcessingTaskTypeClass
  373. * @psalm-param class-string<\OCP\TaskProcessing\ITaskType> $taskProcessingTaskTypeClass
  374. * @return void
  375. * @since 30.0.0
  376. */
  377. public function registerTaskProcessingTaskType(string $taskProcessingTaskTypeClass): void;
  378. /**
  379. * Register a mail provider
  380. *
  381. * @param string $class
  382. * @psalm-param class-string<IMailProvider> $class
  383. * @since 30.0.0
  384. */
  385. public function registerMailProvider(string $class): void;
  386. }