diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-09-25 14:08:34 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-10-19 22:04:20 +0200 |
commit | 08cff0777aac169dd9c758b73faa0060004fc7a0 (patch) | |
tree | c176bf2812e8a97d40cf94d8f0166a136911e30d /lib | |
parent | a6c450b481e439e23be166c84c6fcda45a6a2ebb (diff) | |
download | nextcloud-server-08cff0777aac169dd9c758b73faa0060004fc7a0.tar.gz nextcloud-server-08cff0777aac169dd9c758b73faa0060004fc7a0.zip |
feat(IAppManager): Allow to set the (user) default apps and get all global default apps
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 16 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index ccbb2143133..903e8c2993f 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -38,6 +38,7 @@ */ namespace OC\App; +use InvalidArgumentException; use OC\AppConfig; use OC\AppFramework\Bootstrap\Coordinator; use OC\ServerNotAvailableException; @@ -859,4 +860,19 @@ class AppManager implements IAppManager { return $appId; } + + public function getDefaultApps(): array { + return explode(',', $this->config->getSystemValueString('defaultapp', 'dashboard,files')); + } + + public function setDefaultApps(array $defaultApps): void { + foreach ($defaultApps as $app) { + if (!$this->isInstalled($app)) { + $this->logger->debug('Can not set not installed app as default app', ['missing_app' => $app]); + throw new InvalidArgumentException('App is not installed'); + } + } + + $this->config->setSystemValue('defaultapp', join(',', $defaultApps)); + } } diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 2497544dcbe..f1807399e2a 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -251,4 +251,21 @@ interface IAppManager { * @since 25.0.6 */ public function getDefaultAppForUser(?IUser $user = null): string; + + /** + * Get the global default apps with fallbacks + * + * @return string[] The default applications + * @since 28.0.0 + */ + public function getDefaultApps(): array; + + /** + * Set the global default apps with fallbacks + * + * @param string[] $appId + * @throws \InvalidArgumentException If any of the apps is not installed + * @since 28.0.0 + */ + public function setDefaultApps(array $defaultApps): void; } |