diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 388a743b93696..f2120a925d7d4 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -88,6 +88,9 @@ class AppManager implements IAppManager { /** @var string[] $appId => $enabled */ private $installedAppsCache; + /** @var string[] $appId => $enabled */ + private $enabledAppsCache; + /** @var string[] */ private $shippedApps; @@ -132,7 +135,7 @@ private function getInstalledAppsValues() { } $this->installedAppsCache = array_filter($values, function ($value) { - return $value !== 'no'; + return $value !== ''; }); ksort($this->installedAppsCache); } @@ -147,6 +150,35 @@ private function getInstalledAppsValues() { public function getInstalledApps() { return array_keys($this->getInstalledAppsValues()); } + + /** + * @return string[] $appId => $enabled + */ + private function getEnabledAppsValues() { + if (!$this->enabledAppsCache) { + $values = $this->appConfig->getValues(false, 'enabled'); + + $alwaysEnabledApps = $this->getAlwaysEnabledApps(); + foreach ($alwaysEnabledApps as $appId) { + $values[$appId] = 'yes'; + } + + $this->enabledAppsCache = array_filter($values, function ($value) { + return $value !== 'no'; + }); + ksort($this->enabledAppsCache); + } + return $this->enabledAppsCache; + } + + /** + * List all enabled apps + * + * @return string[] + */ + public function getEnabledApps() { + return array_keys($this->getEnabledAppsValues()); + } /** * List all apps enabled for a user diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 645d5ffd97c9a..df525b4345365 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -156,6 +156,14 @@ public function getEnabledAppsForUser(IUser $user); */ public function getInstalledApps(); + /** + * List all enabled apps + * + * @return string[] + * @since 23.0.0 + */ + public function getEnabledApps(); + /** * Clear the cached list of apps when enabling/disabling an app * @since 8.1.0