IAppManager.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\App;
  8. use OCP\IGroup;
  9. use OCP\IUser;
  10. /**
  11. * Interface IAppManager
  12. *
  13. * @warning This interface shouldn't be included with dependency injection in
  14. * classes used for installing Nextcloud.
  15. *
  16. * @since 8.0.0
  17. */
  18. interface IAppManager {
  19. /**
  20. * Returns the app information from "appinfo/info.xml".
  21. *
  22. * @param string|null $lang
  23. * @return array|null
  24. * @since 14.0.0
  25. */
  26. public function getAppInfo(string $appId, bool $path = false, $lang = null);
  27. /**
  28. * Returns the app information from "appinfo/info.xml".
  29. *
  30. * @param string $appId
  31. * @param bool $useCache
  32. * @return string
  33. * @since 14.0.0
  34. */
  35. public function getAppVersion(string $appId, bool $useCache = true): string;
  36. /**
  37. * Returns the app icon or null if none is found
  38. *
  39. * @param string $appId
  40. * @param bool $dark Enable to request a dark icon variant, default is a white icon
  41. * @return string|null
  42. * @since 29.0.0
  43. */
  44. public function getAppIcon(string $appId, bool $dark = false): string|null;
  45. /**
  46. * Check if an app is enabled for user
  47. *
  48. * @param string $appId
  49. * @param \OCP\IUser|null $user (optional) if not defined, the currently loggedin user will be used
  50. * @return bool
  51. * @since 8.0.0
  52. */
  53. public function isEnabledForUser($appId, $user = null);
  54. /**
  55. * Check if an app is enabled in the instance
  56. *
  57. * Notice: This actually checks if the app is enabled and not only if it is installed.
  58. *
  59. * @param string $appId
  60. * @return bool
  61. * @since 8.0.0
  62. */
  63. public function isInstalled($appId);
  64. /**
  65. * Check if an app should be enabled by default
  66. *
  67. * Notice: This actually checks if the app should be enabled by default
  68. * and not if currently installed/enabled
  69. *
  70. * @param string $appId ID of the app
  71. * @since 25.0.0
  72. */
  73. public function isDefaultEnabled(string $appId):bool;
  74. /**
  75. * Load an app, if not already loaded
  76. * @param string $app app id
  77. * @since 27.0.0
  78. */
  79. public function loadApp(string $app): void;
  80. /**
  81. * Check if an app is loaded
  82. * @param string $app app id
  83. * @since 27.0.0
  84. */
  85. public function isAppLoaded(string $app): bool;
  86. /**
  87. * Enable an app for every user
  88. *
  89. * @param string $appId
  90. * @param bool $forceEnable
  91. * @throws AppPathNotFoundException
  92. * @since 8.0.0
  93. */
  94. public function enableApp(string $appId, bool $forceEnable = false): void;
  95. /**
  96. * Whether a list of types contains a protected app type
  97. *
  98. * @param string[] $types
  99. * @return bool
  100. * @since 12.0.0
  101. */
  102. public function hasProtectedAppType($types);
  103. /**
  104. * Enable an app only for specific groups
  105. *
  106. * @param string $appId
  107. * @param \OCP\IGroup[] $groups
  108. * @param bool $forceEnable
  109. * @throws \Exception
  110. * @since 8.0.0
  111. */
  112. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  113. /**
  114. * Disable an app for every user
  115. *
  116. * @param string $appId
  117. * @param bool $automaticDisabled
  118. * @since 8.0.0
  119. */
  120. public function disableApp($appId, $automaticDisabled = false);
  121. /**
  122. * Get the directory for the given app.
  123. *
  124. * @param string $appId
  125. * @return string
  126. * @since 11.0.0
  127. * @throws AppPathNotFoundException
  128. */
  129. public function getAppPath($appId);
  130. /**
  131. * Get the web path for the given app.
  132. *
  133. * @param string $appId
  134. * @return string
  135. * @since 18.0.0
  136. * @throws AppPathNotFoundException
  137. */
  138. public function getAppWebPath(string $appId): string;
  139. /**
  140. * List all apps enabled for a user
  141. *
  142. * @param \OCP\IUser $user
  143. * @return string[]
  144. * @since 8.1.0
  145. */
  146. public function getEnabledAppsForUser(IUser $user);
  147. /**
  148. * List all installed apps
  149. *
  150. * @return string[]
  151. * @since 8.1.0
  152. */
  153. public function getInstalledApps();
  154. /**
  155. * Clear the cached list of apps when enabling/disabling an app
  156. * @since 8.1.0
  157. */
  158. public function clearAppsCache();
  159. /**
  160. * @param string $appId
  161. * @return boolean
  162. * @since 9.0.0
  163. */
  164. public function isShipped($appId);
  165. /**
  166. * Loads all apps
  167. *
  168. * @param string[] $types
  169. * @return bool
  170. *
  171. * This function walks through the Nextcloud directory and loads all apps
  172. * it can find. A directory contains an app if the file /appinfo/info.xml
  173. * exists.
  174. *
  175. * if $types is set to non-empty array, only apps of those types will be loaded
  176. * @since 27.0.0
  177. */
  178. public function loadApps(array $types = []): bool;
  179. /**
  180. * Check if an app is of a specific type
  181. * @since 27.0.0
  182. */
  183. public function isType(string $app, array $types): bool;
  184. /**
  185. * @return string[]
  186. * @since 9.0.0
  187. */
  188. public function getAlwaysEnabledApps();
  189. /**
  190. * @return string[] app IDs
  191. * @since 25.0.0
  192. */
  193. public function getDefaultEnabledApps(): array;
  194. /**
  195. * @param \OCP\IGroup $group
  196. * @return String[]
  197. * @since 17.0.0
  198. */
  199. public function getEnabledAppsForGroup(IGroup $group): array;
  200. /**
  201. * @param String $appId
  202. * @return string[]
  203. * @since 17.0.0
  204. */
  205. public function getAppRestriction(string $appId): array;
  206. /**
  207. * Returns the id of the user's default app
  208. *
  209. * If `user` is not passed, the currently logged in user will be used
  210. *
  211. * @param ?IUser $user User to query default app for
  212. * @param bool $withFallbacks Include fallback values if no default app was configured manually
  213. * Before falling back to predefined default apps,
  214. * the user defined app order is considered and the first app would be used as the fallback.
  215. *
  216. * @since 25.0.6
  217. * @since 28.0.0 Added optional $withFallbacks parameter
  218. */
  219. public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string;
  220. /**
  221. * Get the global default apps with fallbacks
  222. *
  223. * @return string[] The default applications
  224. * @since 28.0.0
  225. */
  226. public function getDefaultApps(): array;
  227. /**
  228. * Set the global default apps with fallbacks
  229. *
  230. * @param string[] $appId
  231. * @throws \InvalidArgumentException If any of the apps is not installed
  232. * @since 28.0.0
  233. */
  234. public function setDefaultApps(array $defaultApps): void;
  235. }