diff --git a/apps/dav/lib/Command/CreateCalendar.php b/apps/dav/lib/Command/CreateCalendar.php
index 0226a9461b7bf..c48db3bb65cec 100644
--- a/apps/dav/lib/Command/CreateCalendar.php
+++ b/apps/dav/lib/Command/CreateCalendar.php
@@ -22,6 +22,7 @@
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Server;
use Psr\Log\LoggerInterface;
@@ -66,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
Server::get(ProxyMapper::class),
Server::get(KnownUserService::class),
Server::get(IConfig::class),
- \OC::$server->getL10NFactory(),
+ Server::get(IFactory::class),
);
$random = Server::get(ISecureRandom::class);
$logger = Server::get(LoggerInterface::class);
diff --git a/apps/dav/lib/Files/RootCollection.php b/apps/dav/lib/Files/RootCollection.php
index a11bea72c598f..2c01d1ff4baa2 100644
--- a/apps/dav/lib/Files/RootCollection.php
+++ b/apps/dav/lib/Files/RootCollection.php
@@ -8,6 +8,7 @@
namespace OCA\DAV\Files;
use OCP\Files\FileInfo;
+use OCP\Files\IRootFolder;
use OCP\IUserSession;
use OCP\Server;
use Sabre\DAV\INode;
@@ -35,7 +36,7 @@ public function getChildForPrincipal(array $principalInfo) {
// in the future this could be considered to be used for accessing shared files
return new SimpleCollection($name);
}
- $userFolder = \OC::$server->getUserFolder();
+ $userFolder = Server::get(IRootFolder::class)->getUserFolder($user->getUID());
if (!($userFolder instanceof FileInfo)) {
throw new \Exception('Home does not exist');
}
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index 81f98da4c45b4..08e945f47ad37 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -42,6 +42,7 @@
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Server;
use OCP\SystemTag\ISystemTagManager;
@@ -75,7 +76,7 @@ public function __construct() {
$proxyMapper,
Server::get(KnownUserService::class),
Server::get(IConfig::class),
- \OC::$server->getL10NFactory()
+ Server::get(IFactory::class)
);
$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $config);
diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php
index d63ce008435b5..781961e55f7a8 100644
--- a/apps/files_sharing/tests/ExternalStorageTest.php
+++ b/apps/files_sharing/tests/ExternalStorageTest.php
@@ -13,13 +13,15 @@
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
+use OCP\ICertificateManager;
+use OCP\Server;
/**
* Tests for the external Storage class for remote shares.
*/
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
class ExternalStorageTest extends \Test\TestCase {
- public static function optionsProvider() {
+ public static function optionsProvider(): array {
return [
[
'http://remoteserver:8080/owncloud',
@@ -54,7 +56,7 @@ public static function optionsProvider() {
}
private function getTestStorage($uri) {
- $certificateManager = \OC::$server->getCertificateManager();
+ $certificateManager = Server::get(ICertificateManager::class);
$httpClientService = $this->createMock(IClientService::class);
$manager = $this->createMock(ExternalShareManager::class);
$client = $this->createMock(IClient::class);
diff --git a/apps/testing/lib/AppInfo/Application.php b/apps/testing/lib/AppInfo/Application.php
index 22cce3cd4312a..2035dbbf6fce4 100644
--- a/apps/testing/lib/AppInfo/Application.php
+++ b/apps/testing/lib/AppInfo/Application.php
@@ -30,7 +30,9 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\IAppConfig;
use OCP\IGroupManager;
+use OCP\IUserManager;
use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
use OCP\Settings\Events\DeclarativeSettingsRegisterFormEvent;
use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
@@ -67,9 +69,9 @@ public function register(IRegistrationContext $context): void {
public function boot(IBootContext $context): void {
$server = $context->getServerContainer();
- $config = $server->getConfig();
- if ($config->getAppValue(self::APP_ID, 'enable_alt_user_backend', 'no') === 'yes') {
- $userManager = $server->getUserManager();
+ $config = $server->get(IAppConfig::class);
+ if ($config->getValueBool(self::APP_ID, 'enable_alt_user_backend')) {
+ $userManager = $server->get(IUserManager::class);
// replace all user backends with this one
$userManager->clearBackends();
diff --git a/build/integration/features/bootstrap/CalDavContext.php b/build/integration/features/bootstrap/CalDavContext.php
index 2b697c07681ad..a18097bb882c5 100644
--- a/build/integration/features/bootstrap/CalDavContext.php
+++ b/build/integration/features/bootstrap/CalDavContext.php
@@ -12,8 +12,6 @@
use Psr\Http\Message\ResponseInterface;
class CalDavContext implements \Behat\Behat\Context\Context {
- /** @var string */
- private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
@@ -24,9 +22,9 @@ class CalDavContext implements \Behat\Behat\Context\Context {
/**
* @param string $baseUrl
*/
- public function __construct($baseUrl) {
- $this->baseUrl = $baseUrl;
-
+ public function __construct(
+ private $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/CardDavContext.php b/build/integration/features/bootstrap/CardDavContext.php
index bde6177df3914..e7556bbd834a8 100644
--- a/build/integration/features/bootstrap/CardDavContext.php
+++ b/build/integration/features/bootstrap/CardDavContext.php
@@ -12,8 +12,6 @@
use GuzzleHttp\Message\ResponseInterface;
class CardDavContext implements \Behat\Behat\Context\Context {
- /** @var string */
- private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
@@ -21,12 +19,9 @@ class CardDavContext implements \Behat\Behat\Context\Context {
/** @var string */
private $responseXml = '';
- /**
- * @param string $baseUrl
- */
- public function __construct($baseUrl) {
- $this->baseUrl = $baseUrl;
-
+ public function __construct(
+ private string $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/ChecksumsContext.php b/build/integration/features/bootstrap/ChecksumsContext.php
index b569527667a99..86d52f8dba4c2 100644
--- a/build/integration/features/bootstrap/ChecksumsContext.php
+++ b/build/integration/features/bootstrap/ChecksumsContext.php
@@ -11,19 +11,14 @@
use GuzzleHttp\Message\ResponseInterface;
class ChecksumsContext implements \Behat\Behat\Context\Context {
- /** @var string */
- private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
private $response;
- /**
- * @param string $baseUrl
- */
- public function __construct($baseUrl) {
- $this->baseUrl = $baseUrl;
-
+ public function __construct(
+ private string $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/CommandLineContext.php b/build/integration/features/bootstrap/CommandLineContext.php
index 429b7ae3550f8..8b21fcdbf7068 100644
--- a/build/integration/features/bootstrap/CommandLineContext.php
+++ b/build/integration/features/bootstrap/CommandLineContext.php
@@ -17,13 +17,12 @@ class CommandLineContext implements \Behat\Behat\Context\Context {
private $lastTransferPath;
private $featureContext;
- private $localBaseUrl;
- private $remoteBaseUrl;
- public function __construct($ocPath, $baseUrl) {
+ public function __construct(
+ $ocPath,
+ private $baseUrl,
+ ) {
$this->ocPath = rtrim($ocPath, '/') . '/';
- $this->localBaseUrl = $baseUrl;
- $this->remoteBaseUrl = $baseUrl;
}
/**
diff --git a/build/integration/features/bootstrap/CommentsContext.php b/build/integration/features/bootstrap/CommentsContext.php
index 9c9dfafee10ab..594d5617efe79 100644
--- a/build/integration/features/bootstrap/CommentsContext.php
+++ b/build/integration/features/bootstrap/CommentsContext.php
@@ -8,8 +8,6 @@
require __DIR__ . '/autoload.php';
class CommentsContext implements \Behat\Behat\Context\Context {
- /** @var string */
- private $baseUrl;
/** @var array */
private $response;
/** @var int */
@@ -20,9 +18,9 @@ class CommentsContext implements \Behat\Behat\Context\Context {
/**
* @param string $baseUrl
*/
- public function __construct($baseUrl) {
- $this->baseUrl = $baseUrl;
-
+ public function __construct(
+ private $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/ConversionsContext.php b/build/integration/features/bootstrap/ConversionsContext.php
index 223b8ee6b2de9..847e5a9bec5b6 100644
--- a/build/integration/features/bootstrap/ConversionsContext.php
+++ b/build/integration/features/bootstrap/ConversionsContext.php
@@ -1,5 +1,7 @@
baseUrl = $baseUrl;
-
+ public function __construct(
+ private string $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/RateLimitingContext.php b/build/integration/features/bootstrap/RateLimitingContext.php
index 15c8c5c837942..f649396920a5d 100644
--- a/build/integration/features/bootstrap/RateLimitingContext.php
+++ b/build/integration/features/bootstrap/RateLimitingContext.php
@@ -1,5 +1,7 @@
remoteUrl = $remote;
}
protected function getApiClient() {
- return new \OC\Remote\Api\OCS($this->remoteInstance, $this->credentails, \OC::$server->get(IClientService::class));
+ return new OCS($this->remoteInstance, $this->credentails, Server::get(IClientService::class));
}
/**
@@ -43,13 +49,13 @@ protected function getApiClient() {
*/
public function selectRemoteInstance($remoteServer) {
if ($remoteServer == 'REMOTE') {
- $baseUri = $this->remoteUrl;
+ $baseUri = $this->remote;
} else {
$baseUri = 'nonexistingnextcloudserver.local';
}
$this->lastException = null;
try {
- $this->remoteInstance = new \OC\Remote\Instance($baseUri, \OC::$server->getMemCacheFactory()->createLocal(), \OC::$server->get(IClientService::class));
+ $this->remoteInstance = new Instance($baseUri, Server::get(ICacheFactory::class)->createLocal(), Server::get(IClientService::class));
// trigger the status request
$this->remoteInstance->getProtocol();
} catch (\Exception $e) {
@@ -63,7 +69,7 @@ public function selectRemoteInstance($remoteServer) {
*/
public function theRemoteVersionShouldBe($version) {
if ($version === '__current_version__') {
- $version = \OC::$server->getConfig()->getSystemValue('version', '0.0.0.0');
+ $version = Server::get(IConfig::class)->getSystemValue('version', '0.0.0.0');
}
Assert::assertEquals($version, $this->remoteInstance->getVersion());
@@ -83,7 +89,7 @@ public function theRemoteProtocolShouldBe($protocol) {
* @param string $password
*/
public function usingCredentials($user, $password) {
- $this->credentails = new \OC\Remote\Credentials($user, $password);
+ $this->credentails = new Credentials($user, $password);
}
/**
diff --git a/build/integration/features/bootstrap/SetupContext.php b/build/integration/features/bootstrap/SetupContext.php
index 84e8ffcff6d16..35688c26492fb 100644
--- a/build/integration/features/bootstrap/SetupContext.php
+++ b/build/integration/features/bootstrap/SetupContext.php
@@ -1,5 +1,7 @@
$field, "Field '$field' is not a token");
+ Assert::assertMatchesRegularExpression('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token");
} elseif (strpos($contentExpected, 'REGEXP ') === 0) {
- Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match");
+ Assert::assertMatchesRegularExpression(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match");
} else {
Assert::assertEquals($contentExpected, (string)$returnedShare->$field, "Field '$field' does not match");
}
diff --git a/build/integration/features/bootstrap/SharingContext.php b/build/integration/features/bootstrap/SharingContext.php
index c442317a32a38..36c76bf824462 100644
--- a/build/integration/features/bootstrap/SharingContext.php
+++ b/build/integration/features/bootstrap/SharingContext.php
@@ -1,5 +1,7 @@
baseUrl = $baseUrl;
-
+ public function __construct(
+ private $baseUrl,
+ ) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
diff --git a/build/integration/features/bootstrap/autoload.php b/build/integration/features/bootstrap/autoload.php
index a186262ebd302..ac1fb436d0736 100644
--- a/build/integration/features/bootstrap/autoload.php
+++ b/build/integration/features/bootstrap/autoload.php
@@ -1,5 +1,7 @@
principalUri]]>
-
-
-
-
-
@@ -775,11 +770,6 @@
-
-
-
-
-
@@ -830,7 +820,6 @@
-
@@ -2345,13 +2334,6 @@
-
-
-
-
-
-
-
@@ -3951,12 +3933,6 @@
-
-
-
-
-
-
diff --git a/build/rector.php b/build/rector.php
index e94616b16a5a3..f3697174f2199 100644
--- a/build/rector.php
+++ b/build/rector.php
@@ -27,6 +27,7 @@
$nextcloudDir . '/version.php',
$nextcloudDir . '/lib/private',
$nextcloudDir . '/tests',
+ $nextcloudDir . '/build/integration/features/bootstrap',
// $nextcloudDir . '/config',
// $nextcloudDir . '/themes',
])
diff --git a/lib/base.php b/lib/base.php
index fcc6fe700d02f..a11334c50cfd7 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -8,6 +8,7 @@
*/
use OC\Profiler\BuiltInProfiler;
+use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OC\Share20\GroupDeletedListener;
use OC\Share20\Hooks;
use OC\Share20\UserDeletedListener;
@@ -22,6 +23,7 @@
use OCP\IInitialStateService;
use OCP\ILogger;
use OCP\IRequest;
+use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Security\Bruteforce\IThrottler;
@@ -298,7 +300,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
Util::addScript('core', 'update');
$initialState = Server::get(IInitialStateService::class);
- $serverVersion = \OCP\Server::get(\OCP\ServerVersion::class);
+ $serverVersion = Server::get(\OCP\ServerVersion::class);
if ($disableWebUpdater || ($tooBig && !$ignoreTooBigWarning)) {
// send http status 503
http_response_code(503);
@@ -621,7 +623,7 @@ private static function addSecurityHeaders(): void {
* @see \OCP\AppFramework\Http\Response::getHeaders
*/
$policy = 'default-src \'self\'; '
- . 'script-src \'self\' \'nonce-' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '\'; '
+ . 'script-src \'self\' \'nonce-' . Server::get(ContentSecurityPolicyNonceManager::class)->getNonce() . '\'; '
. 'style-src \'self\' \'unsafe-inline\'; '
. 'frame-src *; '
. 'img-src * data: blob:; '
@@ -727,7 +729,7 @@ public static function init(): void {
$config = Server::get(IConfig::class);
if (!defined('PHPUNIT_RUN')) {
$errorHandler = new OC\Log\ErrorHandler(
- \OCP\Server::get(\Psr\Log\LoggerInterface::class),
+ Server::get(\Psr\Log\LoggerInterface::class),
);
$exceptionHandler = [$errorHandler, 'onException'];
if ($config->getSystemValueBool('debug', false)) {
@@ -812,7 +814,7 @@ public static function init(): void {
// User and Groups
if (!$systemConfig->getValue('installed', false)) {
- self::$server->getSession()->set('user_id', '');
+ Server::get(ISession::class)->set('user_id', '');
}
$eventLogger->start('setup_backends', 'Setup group and user backends');
@@ -1076,7 +1078,7 @@ public static function handleRequest(): void {
// Check if Nextcloud is installed or in maintenance (update) mode
if (!$systemConfig->getValue('installed', false)) {
- \OC::$server->getSession()->clear();
+ Server::get(ISession::class)->clear();
$controller = Server::get(\OC\Core\Controller\SetupController::class);
$controller->run($_POST);
exit();
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 49a91cced9c28..8d40aa2d93c60 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -118,7 +118,7 @@ public function __construct(array $parameters) {
}
if ($this->secure === true) {
// inject mock for testing
- $this->certManager = \OC::$server->getCertificateManager();
+ $this->certManager = Server::get(ICertificateManager::class);
}
$this->root = rawurldecode($parameters['root'] ?? '/');
$this->root = '/' . ltrim($this->root, '/');
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 532ac3887c460..05af431c00f12 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -122,7 +122,6 @@
use OC\Security\CredentialsManager;
use OC\Security\Crypto;
use OC\Security\CSP\ContentSecurityPolicyManager;
-use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OC\Security\CSRF\CsrfTokenManager;
use OC\Security\CSRF\TokenStorage\SessionStorage;
use OC\Security\Hasher;
@@ -201,7 +200,6 @@
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Conversion\IConversionManager;
use OCP\Files\Folder;
-use OCP\Files\IAppData;
use OCP\Files\IFilenameValidator;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\IMimeTypeLoader;
@@ -629,7 +627,7 @@ public function __construct(
$this->registerService(IFactory::class, function (Server $c) {
return new \OC\L10N\Factory(
$c->get(IConfig::class),
- $c->getRequest(),
+ $c->get(IRequest::class),
$c->get(IUserSession::class),
$c->get(ICacheFactory::class),
\OC::$SERVERROOT,
@@ -681,7 +679,7 @@ public function __construct(
$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
$l10n = $this->get(IFactory::class)->get('lib');
return new \OC\Activity\Manager(
- $c->getRequest(),
+ $c->get(IRequest::class),
$c->get(IUserSession::class),
$c->get(IConfig::class),
$c->get(IValidator::class),
@@ -702,8 +700,8 @@ public function __construct(
return new AvatarManager(
$c->get(IUserSession::class),
$c->get(\OC\User\Manager::class),
- $c->getAppDataDir('avatar'),
- $c->getL10N('lib'),
+ $c->get(IAppDataFactory::class)->get('avatar'),
+ $c->get(IFactory::class)->get('lib'),
$c->get(LoggerInterface::class),
$c->get(IConfig::class),
$c->get(IAccountManager::class),
@@ -1066,7 +1064,7 @@ public function __construct(
if ($classExists
&& $c->get(IConfig::class)->getSystemValueBool('installed', false)
&& $c->get(IAppManager::class)->isEnabledForAnyone('theming')
- && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
+ && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->get(IRequest::class)->getInsecureServerHost())) {
$backgroundService = new BackgroundService(
$c->get(IRootFolder::class),
$c->get(IAppDataFactory::class)->get('theming'),
@@ -1111,7 +1109,7 @@ public function __construct(
});
$this->registerService(JSCombiner::class, function (Server $c) {
return new JSCombiner(
- $c->getAppDataDir('js'),
+ $c->get(IAppDataFactory::class)->get('js'),
$c->get(IURLGenerator::class),
$this->get(ICacheFactory::class),
$c->get(IConfig::class),
@@ -1352,62 +1350,6 @@ private function connectDispatcher(): void {
GenerateBlurhashMetadata::loadListeners($eventDispatcher);
}
- /**
- * @return \OCP\Contacts\IManager
- * @deprecated 20.0.0
- */
- public function getContactsManager() {
- return $this->get(\OCP\Contacts\IManager::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getEncryptionManager(): \OCP\Encryption\IManager {
- return $this->get(\OCP\Encryption\IManager::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getEncryptionFilesHelper(): IFile {
- return $this->get(IFile::class);
- }
-
- /**
- * The current request object holding all information about the request
- * currently being processed is returned from this method.
- * In case the current execution was not initiated by a web request null is returned
- *
- * @return IRequest
- * @deprecated 20.0.0
- */
- public function getRequest() {
- return $this->get(IRequest::class);
- }
-
- /**
- * Returns the root folder of ownCloud's data directory
- *
- * @return IRootFolder
- * @deprecated 20.0.0
- */
- public function getRootFolder() {
- return $this->get(IRootFolder::class);
- }
-
- /**
- * Returns the root folder of ownCloud's data directory
- * This is the lazy variant so this gets only initialized once it
- * is actually used.
- *
- * @return IRootFolder
- * @deprecated 20.0.0
- */
- public function getLazyRootFolder() {
- return $this->get(IRootFolder::class);
- }
-
/**
* Returns a view to ownCloud's files folder
*
@@ -1427,34 +1369,6 @@ public function getUserFolder($userId = null): ?Folder {
return $root->getUserFolder($userId);
}
- /**
- * @deprecated 20.0.0
- */
- public function getUserManager(): IUserManager {
- return $this->get(IUserManager::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getGroupManager(): IGroupManager {
- return $this->get(IGroupManager::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getUserSession(): IUserSession {
- return $this->get(IUserSession::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getSession(): ISession {
- return $this->get(Session::class)->getSession();
- }
-
public function setSession(ISession $session): void {
$this->get(SessionStorage::class)->setSession($session);
$this->get(Session::class)->setSession($session);
@@ -1462,24 +1376,13 @@ public function setSession(ISession $session): void {
}
/**
+ * Get the webroot
+ *
+ * @return string
* @deprecated 20.0.0
*/
- public function getConfig(): IConfig {
- return $this->get(AllConfig::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getSystemConfig(): SystemConfig {
- return $this->get(SystemConfig::class);
- }
-
- /**
- * @deprecated 20.0.0
- */
- public function getL10NFactory(): IFactory {
- return $this->get(IFactory::class);
+ public function getWebRoot(): string {
+ return $this->webRoot;
}
/**
@@ -1493,241 +1396,4 @@ public function getL10NFactory(): IFactory {
public function getL10N($app, $lang = null) {
return $this->get(IFactory::class)->get($app, $lang);
}
-
- /**
- * @return IURLGenerator
- * @deprecated 20.0.0
- */
- public function getURLGenerator() {
- return $this->get(IURLGenerator::class);
- }
-
- /**
- * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
- * getMemCacheFactory() instead.
- *
- * @return ICache
- * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
- */
- public function getCache() {
- return $this->get(ICache::class);
- }
-
- /**
- * Returns an \OCP\CacheFactory instance
- *
- * @return ICacheFactory
- * @deprecated 20.0.0
- */
- public function getMemCacheFactory() {
- return $this->get(ICacheFactory::class);
- }
-
- /**
- * Returns the current session
- *
- * @return IDBConnection
- * @deprecated 20.0.0
- */
- public function getDatabaseConnection() {
- return $this->get(IDBConnection::class);
- }
-
- /**
- * Returns the activity manager
- *
- * @return \OCP\Activity\IManager
- * @deprecated 20.0.0
- */
- public function getActivityManager() {
- return $this->get(\OCP\Activity\IManager::class);
- }
-
- /**
- * Returns an job list for controlling background jobs
- *
- * @return IJobList
- * @deprecated 20.0.0
- */
- public function getJobList() {
- return $this->get(IJobList::class);
- }
-
- /**
- * Returns a SecureRandom instance
- *
- * @return ISecureRandom
- * @deprecated 20.0.0
- */
- public function getSecureRandom() {
- return $this->get(ISecureRandom::class);
- }
-
- /**
- * Returns a Crypto instance
- *
- * @return ICrypto
- * @deprecated 20.0.0
- */
- public function getCrypto() {
- return $this->get(ICrypto::class);
- }
-
- /**
- * Returns a Hasher instance
- *
- * @return IHasher
- * @deprecated 20.0.0
- */
- public function getHasher() {
- return $this->get(IHasher::class);
- }
-
- /**
- * Get the certificate manager
- *
- * @return ICertificateManager
- */
- public function getCertificateManager() {
- return $this->get(ICertificateManager::class);
- }
-
- /**
- * Get the manager for temporary files and folders
- *
- * @return ITempManager
- * @deprecated 20.0.0
- */
- public function getTempManager() {
- return $this->get(ITempManager::class);
- }
-
- /**
- * Get the app manager
- *
- * @return IAppManager
- * @deprecated 20.0.0
- */
- public function getAppManager() {
- return $this->get(IAppManager::class);
- }
-
- /**
- * Creates a new mailer
- *
- * @return IMailer
- * @deprecated 20.0.0
- */
- public function getMailer() {
- return $this->get(IMailer::class);
- }
-
- /**
- * Get the webroot
- *
- * @return string
- * @deprecated 20.0.0
- */
- public function getWebRoot() {
- return $this->webRoot;
- }
-
- /**
- * Get the locking provider
- *
- * @return ILockingProvider
- * @since 8.1.0
- * @deprecated 20.0.0
- */
- public function getLockingProvider() {
- return $this->get(ILockingProvider::class);
- }
-
- /**
- * Get the MimeTypeDetector
- *
- * @return IMimeTypeDetector
- * @deprecated 20.0.0
- */
- public function getMimeTypeDetector() {
- return $this->get(IMimeTypeDetector::class);
- }
-
- /**
- * Get the MimeTypeLoader
- *
- * @return IMimeTypeLoader
- * @deprecated 20.0.0
- */
- public function getMimeTypeLoader() {
- return $this->get(IMimeTypeLoader::class);
- }
-
- /**
- * Get the Notification Manager
- *
- * @return \OCP\Notification\IManager
- * @since 8.2.0
- * @deprecated 20.0.0
- */
- public function getNotificationManager() {
- return $this->get(\OCP\Notification\IManager::class);
- }
-
- /**
- * @return ThemingDefaults
- * @deprecated 20.0.0
- */
- public function getThemingDefaults() {
- return $this->get('ThemingDefaults');
- }
-
- /**
- * @return Checker
- * @deprecated 20.0.0
- */
- public function getIntegrityCodeChecker() {
- return $this->get('IntegrityCodeChecker');
- }
-
- /**
- * @return CsrfTokenManager
- * @deprecated 20.0.0
- */
- public function getCsrfTokenManager() {
- return $this->get(CsrfTokenManager::class);
- }
-
- /**
- * @return ContentSecurityPolicyNonceManager
- * @deprecated 20.0.0
- */
- public function getContentSecurityPolicyNonceManager() {
- return $this->get(ContentSecurityPolicyNonceManager::class);
- }
-
- /**
- * @return \OCP\Settings\IManager
- * @deprecated 20.0.0
- */
- public function getSettingsManager() {
- return $this->get(\OC\Settings\Manager::class);
- }
-
- /**
- * @return IAppData
- * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
- */
- public function getAppDataDir($app) {
- $factory = $this->get(\OC\Files\AppData\Factory::class);
- return $factory->get($app);
- }
-
- /**
- * @return ICloudIdManager
- * @deprecated 20.0.0
- */
- public function getCloudIdManager() {
- return $this->get(ICloudIdManager::class);
- }
}
diff --git a/lib/public/IServerContainer.php b/lib/public/IServerContainer.php
index 8cab6bc437e70..4580c3890cc48 100644
--- a/lib/public/IServerContainer.php
+++ b/lib/public/IServerContainer.php
@@ -23,36 +23,6 @@
*/
interface IServerContainer extends ContainerInterface, IContainer {
- /**
- * The contacts manager will act as a broker between consumers for contacts information and
- * providers which actual deliver the contact information.
- *
- * @return \OCP\Contacts\IManager
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getContactsManager();
-
- /**
- * The current request object holding all information about the request currently being processed
- * is returned from this method.
- * In case the current execution was not initiated by a web request null is returned
- *
- * @return \OCP\IRequest
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getRequest();
-
- /**
- * Returns the root folder of Nextcloud's data directory
- *
- * @return \OCP\Files\IRootFolder
- * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getRootFolder();
-
/**
* Returns a view to ownCloud's files folder
*
@@ -64,78 +34,9 @@ public function getRootFolder();
*/
public function getUserFolder($userId = null);
- /**
- * Returns a user manager
- *
- * @return \OCP\IUserManager
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getUserManager();
-
- /**
- * Returns a group manager
- *
- * @return \OCP\IGroupManager
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getGroupManager();
-
- /**
- * Returns the user session
- *
- * @return \OCP\IUserSession
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getUserSession();
-
- /**
- * Returns the config manager
- *
- * @return \OCP\IConfig
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getConfig();
-
- /**
- * Returns a Crypto instance
- *
- * @return \OCP\Security\ICrypto
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getCrypto();
-
- /**
- * Returns a Hasher instance
- *
- * @return \OCP\Security\IHasher
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getHasher();
-
- /**
- * Returns a SecureRandom instance
- *
- * @return \OCP\Security\ISecureRandom
- * @since 8.1.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getSecureRandom();
-
- /**
- * @return \OCP\L10N\IFactory
- * @since 8.2.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getL10NFactory();
-
/**
* get an L10N instance
+ *
* @param string $app appid
* @param string $lang
* @return \OCP\IL10N
@@ -144,110 +45,6 @@ public function getL10NFactory();
*/
public function getL10N($app, $lang = null);
- /**
- * @return \OCP\Encryption\IManager
- * @since 8.1.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getEncryptionManager();
-
- /**
- * @return \OCP\Encryption\IFile
- * @since 8.1.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getEncryptionFilesHelper();
-
- /**
- * Returns the URL generator
- *
- * @return \OCP\IURLGenerator
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getURLGenerator();
-
- /**
- * Returns an ICache instance
- *
- * @return \OCP\ICache
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getCache();
-
- /**
- * Returns an \OCP\CacheFactory instance
- *
- * @return \OCP\ICacheFactory
- * @since 7.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getMemCacheFactory();
-
- /**
- * Returns the current session
- *
- * @return \OCP\ISession
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getSession();
-
- /**
- * Returns the activity manager
- *
- * @return \OCP\Activity\IManager
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getActivityManager();
-
- /**
- * Returns the current session
- *
- * @return \OCP\IDBConnection
- * @since 6.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getDatabaseConnection();
-
- /**
- * Returns an job list for controlling background jobs
- *
- * @return \OCP\BackgroundJob\IJobList
- * @since 7.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getJobList();
-
- /**
- * Get the certificate manager
- *
- * @return \OCP\ICertificateManager
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getCertificateManager();
-
- /**
- * Get the manager for temporary files and folders
- *
- * @return \OCP\ITempManager
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getTempManager();
-
- /**
- * Get the app manager
- *
- * @return \OCP\App\IAppManager
- * @since 8.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getAppManager();
-
/**
* Get the webroot
*
@@ -255,57 +52,5 @@ public function getAppManager();
* @since 8.0.0
* @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
*/
- public function getWebRoot();
-
- /**
- * Creates a new mailer
- *
- * @return \OCP\Mail\IMailer
- * @since 8.1.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getMailer();
-
- /**
- * Get the locking provider
- *
- * @return \OCP\Lock\ILockingProvider
- * @since 8.1.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getLockingProvider();
-
- /**
- * Get the MimeTypeDetector
- *
- * @return \OCP\Files\IMimeTypeDetector
- * @since 8.2.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getMimeTypeDetector();
-
- /**
- * Get the MimeTypeLoader
- *
- * @return \OCP\Files\IMimeTypeLoader
- * @since 8.2.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getMimeTypeLoader();
-
- /**
- * Get the Notification Manager
- *
- * @return \OCP\Notification\IManager
- * @since 9.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getNotificationManager();
-
- /**
- * @return \OCP\Federation\ICloudIdManager
- * @since 12.0.0
- * @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get
- */
- public function getCloudIdManager();
+ public function getWebRoot(): string;
}
diff --git a/ocs-provider/index.php b/ocs-provider/index.php
index 28844d9e5817b..74fe6a11034a7 100644
--- a/ocs-provider/index.php
+++ b/ocs-provider/index.php
@@ -6,15 +6,17 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+use OCP\App\IAppManager;
+use OCP\IRequest;
+use OCP\Server;
+
require_once __DIR__ . '/../lib/base.php';
header('Content-Type: application/json');
-$server = \OC::$server;
-
$controller = new \OC\OCS\Provider(
'ocs_provider',
- $server->getRequest(),
- $server->getAppManager()
+ Server::get(IRequest::class),
+ Server::get(IAppManager::class),
);
echo $controller->buildProviderList()->render();
diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php
index d478bea089e63..2587845cbd1e3 100644
--- a/tests/lib/ServerTest.php
+++ b/tests/lib/ServerTest.php
@@ -12,6 +12,7 @@
use OC\Config;
use OC\Server;
use OCP\Comments\ICommentsManager;
+use OCP\IConfig;
/**
* Class Server
@@ -49,17 +50,12 @@ public static function dataTestQuery(): array {
* @param string $instanceOf
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataTestQuery')]
- public function testQuery($serviceName, $instanceOf): void {
+ public function testQuery(string $serviceName, string $instanceOf): void {
$this->assertInstanceOf($instanceOf, $this->server->query($serviceName), 'Service "' . $serviceName . '"" did not return the right class');
}
- public function testGetCertificateManager(): void {
- $this->assertInstanceOf('\OC\Security\CertificateManager', $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class');
- $this->assertInstanceOf('\OCP\ICertificateManager', $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class');
- }
-
public function testOverwriteDefaultCommentsManager(): void {
- $config = $this->server->getConfig();
+ $config = $this->server->get(IConfig::class);
$defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
$config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');