IRegistrationContext.php 12 KB

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