IRegistrationContext.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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 OCP\AppFramework\Bootstrap;
  28. use OCP\AppFramework\IAppContainer;
  29. use OCP\Authentication\TwoFactorAuth\IProvider;
  30. use OCP\Calendar\ICalendarProvider;
  31. use OCP\Capabilities\ICapability;
  32. use OCP\Collaboration\Reference\IReferenceProvider;
  33. use OCP\EventDispatcher\IEventDispatcher;
  34. use OCP\Files\Template\ICustomTemplateProvider;
  35. use OCP\IContainer;
  36. use OCP\Notification\INotifier;
  37. use OCP\Preview\IProviderV2;
  38. use OCP\SpeechToText\ISpeechToTextProvider;
  39. use OCP\Translation\ITranslationProvider;
  40. /**
  41. * The context object passed to IBootstrap::register
  42. *
  43. * @since 20.0.0
  44. * @see IBootstrap::register()
  45. */
  46. interface IRegistrationContext {
  47. /**
  48. * @param string $capability
  49. * @psalm-param class-string<ICapability> $capability
  50. * @see IAppContainer::registerCapability
  51. *
  52. * @since 20.0.0
  53. */
  54. public function registerCapability(string $capability): void;
  55. /**
  56. * Register an implementation of \OCP\Support\CrashReport\IReporter that
  57. * will receive unhandled exceptions and throwables
  58. *
  59. * @param string $reporterClass
  60. * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
  61. * @return void
  62. * @since 20.0.0
  63. */
  64. public function registerCrashReporter(string $reporterClass): void;
  65. /**
  66. * Register an implementation of \OCP\Dashboard\IWidget that
  67. * will handle the implementation of a dashboard widget
  68. *
  69. * @param string $widgetClass
  70. * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
  71. * @return void
  72. * @since 20.0.0
  73. */
  74. public function registerDashboardWidget(string $widgetClass): void;
  75. /**
  76. * Register a service
  77. *
  78. * @param string $name
  79. * @param callable $factory
  80. * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
  81. * @param bool $shared
  82. *
  83. * @return void
  84. * @see IContainer::registerService()
  85. *
  86. * @since 20.0.0
  87. */
  88. public function registerService(string $name, callable $factory, bool $shared = true): void;
  89. /**
  90. * @param string $alias
  91. * @psalm-param string|class-string $alias
  92. * @param string $target
  93. * @psalm-param string|class-string $target
  94. *
  95. * @return void
  96. * @see IContainer::registerAlias()
  97. *
  98. * @since 20.0.0
  99. */
  100. public function registerServiceAlias(string $alias, string $target): void;
  101. /**
  102. * @param string $name
  103. * @param mixed $value
  104. *
  105. * @return void
  106. * @see IContainer::registerParameter()
  107. *
  108. * @since 20.0.0
  109. */
  110. public function registerParameter(string $name, $value): void;
  111. /**
  112. * Register a service listener
  113. *
  114. * This is equivalent to calling IEventDispatcher::addServiceListener
  115. *
  116. * @psalm-template T of \OCP\EventDispatcher\Event
  117. * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
  118. * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
  119. * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
  120. * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
  121. * @param int $priority The higher this value, the earlier an event
  122. * listener will be triggered in the chain (defaults to 0)
  123. *
  124. * @see IEventDispatcher::addServiceListener()
  125. *
  126. * @since 20.0.0
  127. */
  128. public function registerEventListener(string $event, string $listener, int $priority = 0): void;
  129. /**
  130. * @param string $class
  131. * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
  132. * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
  133. *
  134. * @return void
  135. * @see IAppContainer::registerMiddleWare()
  136. *
  137. * @since 20.0.0
  138. * @since 26.0.0 Added optional argument $global
  139. */
  140. public function registerMiddleware(string $class, bool $global = false): void;
  141. /**
  142. * Register a search provider for the unified search
  143. *
  144. * It is allowed to register more than one provider per app as the search
  145. * results can go into distinct sections, e.g. "Files" and "Files shared
  146. * with you" in the Files app.
  147. *
  148. * @param string $class
  149. * @psalm-param class-string<\OCP\Search\IProvider> $class
  150. *
  151. * @return void
  152. *
  153. * @since 20.0.0
  154. */
  155. public function registerSearchProvider(string $class): void;
  156. /**
  157. * Register an alternative login option
  158. *
  159. * It is allowed to register more than one option per app.
  160. *
  161. * @param string $class
  162. * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
  163. *
  164. * @return void
  165. *
  166. * @since 20.0.0
  167. */
  168. public function registerAlternativeLogin(string $class): void;
  169. /**
  170. * Register an initialstate provider
  171. *
  172. * It is allowed to register more than one provider per app.
  173. *
  174. * @param string $class
  175. * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
  176. *
  177. * @return void
  178. *
  179. * @since 21.0.0
  180. */
  181. public function registerInitialStateProvider(string $class): void;
  182. /**
  183. * Register a well known protocol handler
  184. *
  185. * It is allowed to register more than one handler per app.
  186. *
  187. * @param string $class
  188. * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
  189. *
  190. * @return void
  191. *
  192. * @since 21.0.0
  193. */
  194. public function registerWellKnownHandler(string $class): void;
  195. /**
  196. * Register a custom SpeechToText provider class that can provide transcription
  197. * of audio through the OCP\SpeechToText APIs
  198. *
  199. * @param string $providerClass
  200. * @psalm-param class-string<ISpeechToTextProvider> $providerClass
  201. * @since 27.0.0
  202. */
  203. public function registerSpeechToTextProvider(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. * Register an implementation of \OCP\UserMigration\IMigrator that
  305. * will handle the implementation of a migrator
  306. *
  307. * @param string $migratorClass
  308. * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
  309. * @return void
  310. * @since 24.0.0
  311. */
  312. public function registerUserMigrator(string $migratorClass): void;
  313. /**
  314. * Announce methods of classes that may contain sensitive values, which
  315. * should be obfuscated before being logged.
  316. *
  317. * @param string $class
  318. * @param string[] $methods
  319. * @return void
  320. * @since 25.0.0
  321. */
  322. public function registerSensitiveMethods(string $class, array $methods): void;
  323. /**
  324. * Register an implementation of IPublicShareTemplateProvider.
  325. *
  326. * @param string $class
  327. * @psalm-param class-string<\OCP\Share\IPublicShareTemplateProvider> $class
  328. * @return void
  329. * @since 26.0.0
  330. */
  331. public function registerPublicShareTemplateProvider(string $class): void;
  332. }