chore: Replace calls to OC_App::getAppVersions with app manager

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/51676/head
Côme Chilliet 1 year ago
parent 32c1e3e677
commit 4b099bd532
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 22
      apps/updatenotification/lib/Notification/Notifier.php
  2. 12
      core/Command/App/ListApps.php
  3. 7
      lib/private/TemplateLayout.php

@ -20,8 +20,7 @@ use OCP\Notification\IManager;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;
use OCP\Server;
use OCP\Util;
use OCP\ServerVersion;
class Notifier implements INotifier {
/** @var string[] */
@ -44,8 +43,10 @@ class Notifier implements INotifier {
protected IFactory $l10NFactory,
protected IUserSession $userSession,
protected IGroupManager $groupManager,
protected IAppManager $appManager,
protected ServerVersion $serverVersion,
) {
$this->appVersions = $this->getAppVersions();
$this->appVersions = $this->appManager->getAppInstalledVersions();
}
/**
@ -144,15 +145,12 @@ class Notifier implements INotifier {
* @param string $installedVersion
* @throws AlreadyProcessedException When the update is already installed
*/
protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) {
protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion): void {
if (version_compare($notification->getObjectId(), $installedVersion, '<=')) {
throw new AlreadyProcessedException();
}
}
/**
* @return bool
*/
protected function isAdmin(): bool {
$user = $this->userSession->getUser();
@ -164,14 +162,10 @@ class Notifier implements INotifier {
}
protected function getCoreVersions(): string {
return implode('.', Util::getVersion());
}
protected function getAppVersions(): array {
return \OC_App::getAppVersions();
return implode('.', $this->serverVersion->getVersion());
}
protected function getAppInfo($appId, $languageCode) {
return Server::get(IAppManager::class)->getAppInfo($appId, false, $languageCode);
protected function getAppInfo(string $appId, ?string $languageCode): ?array {
return $this->appManager->getAppInfo($appId, false, $languageCode);
}
}

@ -14,7 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class ListApps extends Base {
public function __construct(
protected IAppManager $manager,
protected IAppManager $appManager,
) {
parent::__construct();
}
@ -56,16 +56,16 @@ class ListApps extends Base {
$showEnabledApps = $input->getOption('enabled') || !$input->getOption('disabled');
$showDisabledApps = $input->getOption('disabled') || !$input->getOption('enabled');
$apps = \OC_App::getAllApps();
$apps = $this->appManager->getAllAppsInAppsFolders();
$enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions();
$versions = $this->appManager->getAppInstalledVersions();
//sort enabled apps above disabled apps
foreach ($apps as $app) {
if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) {
if ($shippedFilter !== null && $this->appManager->isShipped($app) !== $shippedFilter) {
continue;
}
if ($this->manager->isEnabledForAnyone($app)) {
if ($this->appManager->isEnabledForAnyone($app)) {
$enabledApps[] = $app;
} else {
$disabledApps[] = $app;
@ -88,7 +88,7 @@ class ListApps extends Base {
sort($disabledApps);
foreach ($disabledApps as $app) {
$apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
$apps['disabled'][$app] = $this->appManager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
}
}

@ -48,6 +48,7 @@ class TemplateLayout {
private InitialStateService $initialState,
private INavigationManager $navigationManager,
private ITemplateManager $templateManager,
private ServerVersion $serverVersion,
) {
}
@ -204,8 +205,8 @@ class TemplateLayout {
if ($this->config->getSystemValueBool('installed', false)) {
if (empty(self::$versionHash)) {
$v = \OC_App::getAppVersions();
$v['core'] = implode('.', \OCP\Util::getVersion());
$v = $this->appManager->getAppInstalledVersions();
$v['core'] = implode('.', $this->serverVersion->getVersion());
self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
}
} else {
@ -220,7 +221,7 @@ class TemplateLayout {
// this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call)
// see https://github.com/nextcloud/server/pull/22636 for details
$jsConfigHelper = new JSConfigHelper(
\OCP\Server::get(ServerVersion::class),
$this->serverVersion,
\OCP\Util::getL10N('lib'),
\OCP\Server::get(Defaults::class),
$this->appManager,

Loading…
Cancel
Save