diff options
author | Patrik Kernstock <info@pkern.at> | 2017-07-05 23:51:16 +0300 |
---|---|---|
committer | Patrik Kernstock <info@pkern.at> | 2017-07-05 23:51:16 +0300 |
commit | 13ef75a29e9d323ddd4a80eb5d3d2b46ac20cb3f (patch) | |
tree | 85d5999f2a7a0c0eb99eb66c8f7829c8790217af /lib/SystemStatistics.php | |
parent | 3d85e156b05edee3aac1c5b9d585a3823fbc0ab9 (diff) |
Rework: Retrieve installed apps using IAppManager
Removing 'num_enabled' key temporary as the new IAppManager-way seems not to provide any reliable way to tell all activated (or even the count) apps. May follow later.
Signed-off-by: Patrik Kernstock <info@pkern.at>
Diffstat (limited to 'lib/SystemStatistics.php')
-rw-r--r-- | lib/SystemStatistics.php | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index 0d421d1..dbcb26c 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -24,7 +24,7 @@ namespace OCA\ServerInfo; use OC\Files\View; use OCP\IConfig; -use \OC_App; +use OCP\App\IAppManager; use OC\App\AppStore\Fetcher\AppFetcher; class SystemStatistics { @@ -35,16 +35,19 @@ class SystemStatistics { private $view; /** @var appFetcher */ private $appFetcher; + /** @var appManager */ + private $appManager; /** * SystemStatistics constructor. * - * @param IConfig $config - * @param AppFetcher $appFetcher + * @param IConfig $config + * @param IAppManager $appManager */ - public function __construct(IConfig $config, AppFetcher $appFetcher) { + public function __construct(IConfig $config, IAppManager $appManager, AppFetcher $appFetcher) { $this->config = $config; $this->view = new View(); + $this->appManager = $appManager; $this->appFetcher = $appFetcher; } @@ -120,27 +123,22 @@ class SystemStatistics { // sekeleton about the data we return back $info = [ 'num_installed' => 0, - 'num_enabled' => 0, 'num_updates_available' => 0, 'app_updates' => [], ]; // load all apps - $apps = (new OC_App())->listAllApps(); - foreach($apps as $key => $app) { - // count installed apps - $info['num_installed']++; - // count activated apps - if ($app['active']) { - $info['num_enabled']++; - } + $apps = $this->appManager->getInstalledApps(); + $info['num_installed'] = count($apps); + // iteriate through all installed apps. + foreach($apps as $app) { // check if there is any new version available for that specific app - $newVersion = \OC\Installer::isUpdateAvailable($app['id'], $this->appFetcher); + $newVersion = \OC\Installer::isUpdateAvailable($app, $this->appFetcher); if ($newVersion) { // new version available, count up and tell which version. $info['num_updates_available']++; - $info['app_updates'][$app['id']] = $newVersion; + $info['app_updates'][$app] = $newVersion; } } |