Browse Source

feat(IAppManager): Allow to set the (user) default apps and get all global default apps

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/40844/head
Ferdinand Thiessen 2 years ago
parent
commit
08cff0777a
No known key found for this signature in database GPG Key ID: 45FAE7268762B400
  1. 16
      lib/private/App/AppManager.php
  2. 17
      lib/public/App/IAppManager.php

16
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));
}
}

17
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;
}
Loading…
Cancel
Save