aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-03-24 17:21:17 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-03-25 14:23:40 +0100
commit4b099bd532448b1ab4ec11f9a88d7074fe856fa2 (patch)
treef0ae94b5a390d26da7851d46bfddfd37a07b4830
parent32c1e3e677a117501e51f27731d4b6e7f0484e14 (diff)
downloadnextcloud-server-4b099bd532448b1ab4ec11f9a88d7074fe856fa2.tar.gz
nextcloud-server-4b099bd532448b1ab4ec11f9a88d7074fe856fa2.zip
chore: Replace calls to OC_App::getAppVersions with app manager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--apps/updatenotification/lib/Notification/Notifier.php22
-rw-r--r--core/Command/App/ListApps.php12
-rw-r--r--lib/private/TemplateLayout.php7
3 files changed, 18 insertions, 23 deletions
diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php
index 8cee44144b2..8ce6bfc2d3d 100644
--- a/apps/updatenotification/lib/Notification/Notifier.php
+++ b/apps/updatenotification/lib/Notification/Notifier.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);
}
}
diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php
index 5244d66e0d8..bb59e441119 100644
--- a/core/Command/App/ListApps.php
+++ b/core/Command/App/ListApps.php
@@ -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] . ')' : '');
}
}
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index 9c1d7ca1d2c..01d22edc0fb 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -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,