diff --git a/core/register_command.php b/core/register_command.php
index d9e5dfcd775eb..66b3ad91ec4da 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -48,7 +48,9 @@
* along with this program. If not, see
*
*/
-use Psr\Log\LoggerInterface;
+
+ use OCP\App\IAppManager;
+ use Psr\Log\LoggerInterface;
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status(\OC::$server->get(\OCP\IConfig::class), \OC::$server->get(\OCP\Defaults::class)));
@@ -72,12 +74,12 @@
if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
- $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));
- $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager()));
+ $application->add(new OC\Core\Command\App\Disable(\OC::$server->get(IAppManager::class)));
+ $application->add(new OC\Core\Command\App\Enable(\OC::$server->get(IAppManager::class), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\App\Install());
$application->add(new OC\Core\Command\App\GetPath());
- $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
- $application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->get(LoggerInterface::class)));
+ $application->add(new OC\Core\Command\App\ListApps(\OC::$server->get(IAppManager::class)));
+ $application->add(new OC\Core\Command\App\Remove(\OC::$server->get(IAppManager::class), \OC::$server->query(\OC\Installer::class), \OC::$server->get(LoggerInterface::class)));
$application->add(\OC::$server->query(\OC\Core\Command\App\Update::class));
$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class));
@@ -116,7 +118,7 @@
if (\OC::$server->getConfig()->getSystemValueBool('debug', false)) {
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->get(\OC\DB\Connection::class)));
- $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getAppManager()));
+ $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->get(IAppManager::class)));
$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getConfig()));
}
@@ -125,10 +127,10 @@
$application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager()));
- $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
+ $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->get(IAppManager::class), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
$application->add(new OC\Core\Command\Encryption\DecryptAll(
\OC::$server->getEncryptionManager(),
- \OC::$server->getAppManager(),
+ \OC::$server->get(IAppManager::class),
\OC::$server->getConfig(),
new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()),
new \Symfony\Component\Console\Helper\QuestionHelper())
@@ -174,7 +176,7 @@
new \OC\Repair([], \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)),
\OC::$server->getConfig(),
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
- \OC::$server->getAppManager()
+ \OC::$server->get(IAppManager::class)
));
$application->add(\OC::$server->query(OC\Core\Command\Maintenance\RepairShareOwnership::class));
@@ -188,7 +190,7 @@
$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
- $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager()));
+ $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->get(IAppManager::class)));
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index a012d1e8ea69f..9d805957e1589 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -51,6 +51,7 @@
use OC\ServerContainer;
use OC\Settings\AuthorizedGroupMapper;
use OCA\WorkflowEngine\Manager;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\QueryException;
@@ -255,7 +256,7 @@ public function __construct(string $appName, array $urlParams = [], ServerContai
$server->getUserSession()->isLoggedIn(),
$this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()),
$server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()),
- $server->getAppManager(),
+ $server->get(IAppManager::class),
$server->getL10N('lib'),
$c->get(AuthorizedGroupMapper::class),
$server->get(IUserSession::class)
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index dc81135b64410..e8680fb871e3e 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -494,7 +494,7 @@ public function isDownloaded($name) {
*/
public function removeApp($appId) {
if ($this->isDownloaded($appId)) {
- if (\OC::$server->getAppManager()->isShipped($appId)) {
+ if (\OC::$server->get(IAppManager::class)->isShipped($appId)) {
return false;
}
$appDir = OC_App::getInstallPath() . '/' . $appId;
@@ -537,7 +537,7 @@ public function installAppBundle(Bundle $bundle) {
* @return array Array of error messages (appid => Exception)
*/
public static function installShippedApps($softErrors = false) {
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
$config = \OC::$server->getConfig();
$errors = [];
foreach (\OC::$APPSROOTS as $app_dir) {
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index 8c01d6609155c..12ead3b576d21 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -41,6 +41,7 @@
use OCA\ShareByMail\Settings\SettingsManager;
use OCA\ShareByMail\ShareByMailProvider;
use OCA\Talk\Share\RoomShareProvider;
+use OCP\App\IAppManager;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
@@ -121,7 +122,7 @@ protected function federatedShareProvider() {
/*
* Check if the app is enabled
*/
- $appManager = $this->serverContainer->getAppManager();
+ $appManager = $this->serverContainer->get(IAppManager::class);
if (!$appManager->isEnabledForUser('federatedfilesharing')) {
return null;
}
@@ -178,7 +179,7 @@ protected function getShareByMailProvider() {
/*
* Check if the app is enabled
*/
- $appManager = $this->serverContainer->getAppManager();
+ $appManager = $this->serverContainer->get(IAppManager::class);
if (!$appManager->isEnabledForUser('sharebymail')) {
return null;
}
@@ -220,7 +221,7 @@ protected function getShareByCircleProvider() {
return null;
}
- if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
+ if (!$this->serverContainer->get(IAppManager::class)->isEnabledForUser('circles') ||
!class_exists('\OCA\Circles\ShareByCircleProvider')
) {
$this->circlesAreNotAvailable = true;
@@ -252,7 +253,7 @@ protected function getRoomShareProvider() {
/*
* Check if the app is enabled
*/
- $appManager = $this->serverContainer->getAppManager();
+ $appManager = $this->serverContainer->get(IAppManager::class);
if (!$appManager->isEnabledForUser('spreed')) {
return null;
}
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index 658a85152bf49..390ce778da88a 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -47,6 +47,7 @@
use OC\Template\CSSResourceLocator;
use OC\Template\JSConfigHelper;
use OC\Template\JSResourceLocator;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
use OCP\IConfig;
@@ -87,7 +88,7 @@ public function __construct($renderAs, $appId = '') {
// Add fallback theming variables if theming is disabled
if ($renderAs !== TemplateResponse::RENDER_AS_USER
- || !\OC::$server->getAppManager()->isEnabledForUser('theming')) {
+ || !\OC::$server->get(IAppManager::class)->isEnabledForUser('theming')) {
// TODO cache generated default theme if enabled for fallback if server is erroring ?
Util::addStyle('theming', 'default');
}
@@ -113,7 +114,7 @@ public function __construct($renderAs, $appId = '') {
// Set body data-theme
$this->assign('enabledThemes', []);
- if (\OC::$server->getAppManager()->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
+ if (\OC::$server->get(IAppManager::class)->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
/** @var \OCA\Theming\Service\ThemesService */
$themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class);
$this->assign('enabledThemes', $themesService->getEnabledThemes());
@@ -124,8 +125,8 @@ public function __construct($renderAs, $appId = '') {
$this->assign('logoUrl', $logoUrl);
// Set default app name
- $defaultApp = \OC::$server->getAppManager()->getDefaultAppForUser();
- $defaultAppInfo = \OC::$server->getAppManager()->getAppInfo($defaultApp);
+ $defaultApp = \OC::$server->get(IAppManager::class)->getDefaultAppForUser();
+ $defaultAppInfo = \OC::$server->get(IAppManager::class)->getAppInfo($defaultApp);
$l10n = \OC::$server->getL10NFactory()->get($defaultApp);
$this->assign('defaultAppName', $l10n->t($defaultAppInfo['name']));
@@ -227,7 +228,7 @@ public function __construct($renderAs, $appId = '') {
$jsConfigHelper = new JSConfigHelper(
\OC::$server->getL10N('lib'),
\OCP\Server::get(Defaults::class),
- \OC::$server->getAppManager(),
+ \OC::$server->get(IAppManager::class),
\OC::$server->getSession(),
\OC::$server->getUserSession()->getUser(),
$this->config,
@@ -312,7 +313,7 @@ protected function getVersionHashSuffix($path = false, $file = false) {
$v = [];
if ($this->config->getSystemValueBool('installed', false)) {
- if (\OC::$server->getAppManager()->isInstalled('theming')) {
+ if (\OC::$server->get(IAppManager::class)->isInstalled('theming')) {
$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
}
$v = \OC_App::getAppVersions();
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 5a14bb1750779..35cdf70ddb228 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -275,7 +275,7 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo
\OC::$server->getAppFetcher()->setVersion($currentVersion);
/** @var AppManager $appManager */
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
// upgrade appstore apps
$this->upgradeAppStoreApps($appManager->getInstalledApps());
@@ -382,7 +382,7 @@ private function checkAppsRequirements(): void {
$isCoreUpgrade = $this->isCodeUpgrade();
$apps = OC_App::getEnabledApps();
$version = implode('.', Util::getVersion());
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
foreach ($apps as $app) {
// check if the app is compatible with this version of Nextcloud
$info = $appManager->getAppInfo($app);
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index ac449a62a4ffb..e83d99bc48126 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -183,7 +183,7 @@ public static function isType(string $app, array $types): bool {
* read app types from info.xml and cache them in the database
*/
public static function setAppTypes(string $app) {
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
$appData = $appManager->getAppInfo($app);
if (!is_array($appData)) {
return;
@@ -221,7 +221,7 @@ public static function getEnabledApps(bool $forceRefresh = false, bool $all = fa
}
// in incognito mode or when logged out, $user will be false,
// which is also the case during an upgrade
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
if ($all) {
$user = null;
} else {
@@ -264,7 +264,7 @@ public function enable(string $appId,
$installer->installApp($appId);
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
if ($groups !== []) {
$groupManager = \OC::$server->getGroupManager();
$groupsList = [];
@@ -354,7 +354,7 @@ public static function findAppInDirectories(string $appId, bool $ignoreCache = f
* @param string $appId
* @param bool $refreshAppPath should be set to true only during install/upgrade
* @return string|false
- * @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
+ * @deprecated 11.0.0 use \OC::$server->get(\OCP\App\IAppManager::class)->getAppPath()
*/
public static function getAppPath(string $appId, bool $refreshAppPath = false) {
if ($appId === null || trim($appId) === '') {
@@ -373,7 +373,7 @@ public static function getAppPath(string $appId, bool $refreshAppPath = false) {
*
* @param string $appId
* @return string|false
- * @deprecated 18.0.0 use \OC::$server->getAppManager()->getAppWebPath()
+ * @deprecated 18.0.0 use \OC::$server->get(\OCP\App\IAppManager::class)->getAppWebPath()
*/
public static function getAppWebPath(string $appId) {
if (($dir = self::findAppInDirectories($appId)) != false) {
@@ -390,7 +390,7 @@ public static function getAppWebPath(string $appId) {
*/
public static function getAppVersionByPath(string $path): string {
$infoFile = $path . '/appinfo/info.xml';
- $appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true);
+ $appData = \OC::$server->get(IAppManager::class)->getAppInfo($infoFile, true);
return isset($appData['version']) ? $appData['version'] : '';
}
@@ -556,7 +556,7 @@ public function getSupportedApps(): array {
public function listAllApps(): array {
$installedApps = OC_App::getAllApps();
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
//we don't want to show configuration for these
$blacklist = $appManager->getAlwaysEnabledApps();
$appList = [];
@@ -756,7 +756,7 @@ public static function updateApp(string $appId): bool {
return false;
}
- \OC::$server->getAppManager()->clearAppsCache();
+ \OC::$server->get(IAppManager::class)->clearAppsCache();
$l = \OC::$server->getL10N('core');
$appData = \OCP\Server::get(\OCP\App\IAppManager::class)->getAppInfo($appId, false, $l->getLanguageCode());
@@ -778,8 +778,8 @@ public static function updateApp(string $appId): bool {
self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);
// update appversion in app manager
- \OC::$server->getAppManager()->clearAppsCache();
- \OC::$server->getAppManager()->getAppVersion($appId, false);
+ \OC::$server->get(IAppManager::class)->clearAppsCache();
+ \OC::$server->get(IAppManager::class)->getAppVersion($appId, false);
self::setupBackgroundJobs($appData['background-jobs']);
@@ -862,7 +862,7 @@ private static function setupLiveMigrations(string $appId, array $steps) {
* @return \OC\Files\View|false
*/
public static function getStorage(string $appId) {
- if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
+ if (\OC::$server->get(IAppManager::class)->isEnabledForUser($appId)) { //sanity check
if (\OC::$server->getUserSession()->isLoggedIn()) {
$view = new \OC\Files\View('/' . OC_User::getUser());
if (!$view->file_exists($appId)) {
diff --git a/lib/private/legacy/OC_JSON.php b/lib/private/legacy/OC_JSON.php
index b9cfb8210e09f..b67d82481d00d 100644
--- a/lib/private/legacy/OC_JSON.php
+++ b/lib/private/legacy/OC_JSON.php
@@ -27,6 +27,9 @@
* along with this program. If not, see
*
*/
+
+ use OCP\App\IAppManager;
+
class OC_JSON {
/**
* Check if the app is enabled, send json error msg if not
@@ -35,7 +38,7 @@ class OC_JSON {
* @suppress PhanDeprecatedFunction
*/
public static function checkAppEnabled($app) {
- if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
+ if (!\OC::$server->get(IAppManager::class)->isEnabledForUser($app)) {
$l = \OC::$server->getL10N('lib');
self::error([ 'data' => [ 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ]]);
exit();
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php
index 974f26fa38122..80979fb529c14 100644
--- a/lib/private/legacy/OC_Template.php
+++ b/lib/private/legacy/OC_Template.php
@@ -38,6 +38,7 @@
*
*/
use OC\TemplateLayout;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
require_once __DIR__.'/template/functions.php';
@@ -240,7 +241,7 @@ public static function printGuestPage($application, $name, $parameters = []) {
* @suppress PhanAccessMethodInternal
*/
public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) {
- if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
+ if (\OC::$server->get(IAppManager::class)->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
\OC_App::loadApp('theming');
}
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 9d62c46137e61..d34272b95d676 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -66,6 +66,7 @@
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Files\SetupManager;
+use OCP\App\IAppManager;
use OCP\Files\Template\ITemplateManager;
use OCP\IConfig;
use OCP\IGroupManager;
@@ -83,7 +84,7 @@ class OC_Util {
private static $versionCache = null;
protected static function getAppManager() {
- return \OC::$server->getAppManager();
+ return \OC::$server->get(IAppManager::class);
}
/**
diff --git a/ocm-provider/index.php b/ocm-provider/index.php
index 1b90fd5366560..ee38827fdea95 100644
--- a/ocm-provider/index.php
+++ b/ocm-provider/index.php
@@ -22,11 +22,13 @@
require_once __DIR__ . '/../lib/base.php';
+use OCP\App\IAppManager;
+
header('Content-Type: application/json');
$server = \OC::$server;
-$isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api');
+$isEnabled = $server->get(IAppManager::class)->isEnabledForUser('cloud_federation_api');
if ($isEnabled) {
// Make sure the routes are loaded
diff --git a/ocs-provider/index.php b/ocs-provider/index.php
index 13dfa0b377913..5425bb061fb74 100644
--- a/ocs-provider/index.php
+++ b/ocs-provider/index.php
@@ -21,6 +21,8 @@
require_once __DIR__ . '/../lib/base.php';
+use OCP\App\IAppManager;
+
header('Content-Type: application/json');
$server = \OC::$server;
@@ -28,6 +30,6 @@
$controller = new \OC\OCS\Provider(
'ocs_provider',
$server->getRequest(),
- $server->getAppManager()
+ $server->get(IAppManager::class)
);
echo $controller->buildProviderList()->render();
diff --git a/public.php b/public.php
index 2956d7f79dd81..2163d7ce04f23 100644
--- a/public.php
+++ b/public.php
@@ -32,6 +32,8 @@
*/
require_once __DIR__ . '/lib/versioncheck.php';
+use OCP\App\IAppManager;
+
try {
require_once __DIR__ . '/lib/base.php';
if (\OCP\Util::needUpgrade()) {
@@ -69,7 +71,7 @@
OC_App::loadApps(['extended_authentication']);
OC_App::loadApps(['filesystem', 'logging']);
- if (!\OC::$server->getAppManager()->isInstalled($app)) {
+ if (!\OC::$server->get(IAppManager::class)->isInstalled($app)) {
http_response_code(404);
exit;
}
diff --git a/remote.php b/remote.php
index 0c33fabc762aa..d82948a84421d 100644
--- a/remote.php
+++ b/remote.php
@@ -34,6 +34,7 @@
require_once __DIR__ . '/lib/versioncheck.php';
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
+use OCP\App\IAppManager;
use Sabre\DAV\Exception\ServiceUnavailable;
use Sabre\DAV\Server;
use Psr\Log\LoggerInterface;
@@ -161,7 +162,7 @@ function resolveService($service) {
$file = OC::$SERVERROOT .'/'. $file;
break;
default:
- if (!\OC::$server->getAppManager()->isInstalled($app)) {
+ if (!\OC::$server->get(IAppManager::class)->isInstalled($app)) {
throw new RemoteException('App not installed: ' . $app);
}
OC_App::loadApp($app);
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php
index 2b276948b0433..bb1ca9692385a 100644
--- a/tests/Core/Command/Apps/AppsDisableTest.php
+++ b/tests/Core/Command/Apps/AppsDisableTest.php
@@ -24,6 +24,7 @@
namespace Tests\Core\Command\Config;
use OC\Core\Command\App\Disable;
+use OCP\App\IAppManager;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;
@@ -40,13 +41,13 @@ protected function setUp(): void {
parent::setUp();
$command = new Disable(
- \OC::$server->getAppManager()
+ \OC::$server->get(IAppManager::class)
);
$this->commandTester = new CommandTester($command);
- \OC::$server->getAppManager()->enableApp('admin_audit');
- \OC::$server->getAppManager()->enableApp('comments');
+ \OC::$server->get(IAppManager::class)->enableApp('admin_audit');
+ \OC::$server->get(IAppManager::class)->enableApp('comments');
}
/**
diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php
index 6e5774641038e..96014bb7d142b 100644
--- a/tests/Core/Command/Apps/AppsEnableTest.php
+++ b/tests/Core/Command/Apps/AppsEnableTest.php
@@ -24,6 +24,7 @@
namespace Tests\Core\Command\Config;
use OC\Core\Command\App\Enable;
+use OCP\App\IAppManager;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;
@@ -40,14 +41,14 @@ protected function setUp(): void {
parent::setUp();
$command = new Enable(
- \OC::$server->getAppManager(),
+ \OC::$server->get(IAppManager::class),
\OC::$server->getGroupManager()
);
$this->commandTester = new CommandTester($command);
- \OC::$server->getAppManager()->disableApp('admin_audit');
- \OC::$server->getAppManager()->disableApp('comments');
+ \OC::$server->get(IAppManager::class)->disableApp('admin_audit');
+ \OC::$server->get(IAppManager::class)->disableApp('comments');
}
/**
diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php
index aa15ea7f562d9..d9af4039f7264 100644
--- a/tests/lib/Preview/BackgroundCleanupJobTest.php
+++ b/tests/lib/Preview/BackgroundCleanupJobTest.php
@@ -25,6 +25,7 @@
use OC\Preview\BackgroundCleanupJob;
use OC\Preview\Storage\Root;
use OC\PreviewManager;
+use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\File;
use OCP\Files\IMimeTypeLoader;
@@ -78,7 +79,7 @@ protected function setUp(): void {
$this->logout();
$this->loginAsUser($this->userId);
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
$this->trashEnabled = $appManager->isEnabledForUser('files_trashbin', $user);
$appManager->disableApp('files_trashbin');
@@ -91,7 +92,7 @@ protected function setUp(): void {
protected function tearDown(): void {
if ($this->trashEnabled) {
- $appManager = \OC::$server->getAppManager();
+ $appManager = \OC::$server->get(IAppManager::class);
$appManager->enableApp('files_trashbin');
}