aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-02-03 15:34:01 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-02-13 11:46:42 +0100
commit64863c9d4631c42d4ce3997d7033bca8f06ca66a (patch)
treeb7e88154522cd827da8163719aeb91b51d5640cd /apps/dav
parent007335dadfcda18330bb853a73bf451ed41c8254 (diff)
downloadnextcloud-server-64863c9d4631c42d4ce3997d7033bca8f06ca66a.tar.gz
nextcloud-server-64863c9d4631c42d4ce3997d7033bca8f06ca66a.zip
chore: Apply new rector configuration to apps folder
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/appinfo/v1/caldav.php63
-rw-r--r--apps/dav/appinfo/v1/carddav.php60
-rw-r--r--apps/dav/appinfo/v1/publicwebdav.php41
-rw-r--r--apps/dav/appinfo/v1/webdav.php46
-rw-r--r--apps/dav/appinfo/v2/direct.php18
-rw-r--r--apps/dav/appinfo/v2/remote.php3
-rw-r--r--apps/dav/lib/AppInfo/Application.php5
-rw-r--r--apps/dav/lib/Avatars/RootCollection.php3
-rw-r--r--apps/dav/lib/CalDAV/CalendarHome.php6
-rw-r--r--apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php12
-rw-r--r--apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php3
-rw-r--r--apps/dav/lib/CardDAV/UserAddressBooks.php6
-rw-r--r--apps/dav/lib/Command/CreateCalendar.php28
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php9
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php20
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php11
-rw-r--r--apps/dav/lib/Connector/Sabre/ServerFactory.php23
-rw-r--r--apps/dav/lib/Files/BrowserErrorPagePlugin.php2
-rw-r--r--apps/dav/lib/Files/RootCollection.php4
-rw-r--r--apps/dav/lib/Listener/UserEventsListener.php5
-rw-r--r--apps/dav/lib/RootCollection.php58
-rw-r--r--apps/dav/lib/Server.php122
-rw-r--r--apps/dav/lib/Upload/UploadFolder.php4
-rw-r--r--apps/dav/lib/Upload/UploadHome.php4
-rw-r--r--apps/dav/templates/settings-admin-caldav.php2
-rw-r--r--apps/dav/templates/settings-personal-availability.php2
-rw-r--r--apps/dav/tests/integration/Db/PropertyMapperTest.php3
-rw-r--r--apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php5
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php15
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php17
-rw-r--r--apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php6
-rw-r--r--apps/dav/tests/unit/CardDAV/CardDavBackendTest.php3
-rw-r--r--apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php6
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php6
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php7
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php7
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php3
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php26
-rw-r--r--apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php2
-rw-r--r--apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php10
42 files changed, 402 insertions, 284 deletions
diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php
index ea6d2dcf406..2cee1866a36 100644
--- a/apps/dav/appinfo/v1/caldav.php
+++ b/apps/dav/appinfo/v1/caldav.php
@@ -20,38 +20,47 @@ use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
+use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IGroupManager;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Security\Bruteforce\IThrottler;
+use OCP\Security\ISecureRandom;
use OCP\Server;
use Psr\Log\LoggerInterface;
$authBackend = new Auth(
- \OC::$server->getSession(),
- \OC::$server->getUserSession(),
- \OC::$server->getRequest(),
- \OC::$server->getTwoFactorAuthManager(),
- \OC::$server->getBruteForceThrottler(),
+ Server::get(ISession::class),
+ Server::get(IUserSession::class),
+ Server::get(IRequest::class),
+ Server::get(\OC\Authentication\TwoFactorAuth\Manager::class),
+ Server::get(IThrottler::class),
'principals/'
);
$principalBackend = new Principal(
- \OC::$server->getUserManager(),
- \OC::$server->getGroupManager(),
- \OC::$server->get(IAccountManager::class),
- \OC::$server->getShareManager(),
- \OC::$server->getUserSession(),
- \OC::$server->getAppManager(),
- \OC::$server->query(ProxyMapper::class),
- \OC::$server->get(KnownUserService::class),
- \OC::$server->getConfig(),
+ Server::get(IUserManager::class),
+ Server::get(IGroupManager::class),
+ Server::get(IAccountManager::class),
+ Server::get(\OCP\Share\IManager::class),
+ Server::get(IUserSession::class),
+ Server::get(IAppManager::class),
+ Server::get(ProxyMapper::class),
+ Server::get(KnownUserService::class),
+ Server::get(IConfig::class),
\OC::$server->getL10NFactory(),
'principals/'
);
-$db = \OC::$server->getDatabaseConnection();
-$userManager = \OC::$server->getUserManager();
-$random = \OC::$server->getSecureRandom();
-$logger = \OC::$server->get(LoggerInterface::class);
-$dispatcher = \OC::$server->get(IEventDispatcher::class);
-$config = \OC::$server->get(IConfig::class);
+$db = Server::get(IDBConnection::class);
+$userManager = Server::get(IUserManager::class);
+$random = Server::get(ISecureRandom::class);
+$logger = Server::get(LoggerInterface::class);
+$dispatcher = Server::get(IEventDispatcher::class);
+$config = Server::get(IConfig::class);
$calDavBackend = new CalDavBackend(
$db,
@@ -61,12 +70,12 @@ $calDavBackend = new CalDavBackend(
$logger,
$dispatcher,
$config,
- OC::$server->get(\OCA\DAV\CalDAV\Sharing\Backend::class),
+ Server::get(\OCA\DAV\CalDAV\Sharing\Backend::class),
true
);
-$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
-$sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
+$debugging = Server::get(IConfig::class)->getSystemValue('debug', false);
+$sendInvitations = Server::get(IConfig::class)->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
// Root nodes
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
@@ -83,11 +92,11 @@ $nodes = [
// Fire up server
$server = new \Sabre\DAV\Server($nodes);
$server::$exposeVersion = false;
-$server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri());
+$server->httpRequest->setUrl(Server::get(IRequest::class)->getRequestUri());
$server->setBaseUri($baseuri);
// Add plugins
-$server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OC::$server->getL10N('dav')));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
$server->addPlugin(new \Sabre\CalDAV\Plugin());
@@ -98,10 +107,10 @@ if ($debugging) {
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
$server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
-$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
+$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(DefaultCalendarValidator::class)));
if ($sendInvitations) {
- $server->addPlugin(\OC::$server->query(IMipPlugin::class));
+ $server->addPlugin(Server::get(IMipPlugin::class));
}
$server->addPlugin(new ExceptionLoggerPlugin('caldav', $logger));
$server->addPlugin(Server::get(RateLimitingPlugin::class));
diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php
index dbcdacc27f0..0220332297e 100644
--- a/apps/dav/appinfo/v1/carddav.php
+++ b/apps/dav/appinfo/v1/carddav.php
@@ -23,49 +23,57 @@ use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\AppData\IAppDataFactory;
+use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IGroupManager;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Security\Bruteforce\IThrottler;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\Plugin;
$authBackend = new Auth(
- \OC::$server->getSession(),
- \OC::$server->getUserSession(),
- \OC::$server->getRequest(),
- \OC::$server->getTwoFactorAuthManager(),
- \OC::$server->getBruteForceThrottler(),
+ Server::get(ISession::class),
+ Server::get(IUserSession::class),
+ Server::get(IRequest::class),
+ Server::get(\OC\Authentication\TwoFactorAuth\Manager::class),
+ Server::get(IThrottler::class),
'principals/'
);
$principalBackend = new Principal(
- \OC::$server->getUserManager(),
- \OC::$server->getGroupManager(),
- \OC::$server->get(IAccountManager::class),
- \OC::$server->getShareManager(),
- \OC::$server->getUserSession(),
- \OC::$server->getAppManager(),
- \OC::$server->query(ProxyMapper::class),
- \OC::$server->get(KnownUserService::class),
- \OC::$server->getConfig(),
+ Server::get(IUserManager::class),
+ Server::get(IGroupManager::class),
+ Server::get(IAccountManager::class),
+ Server::get(\OCP\Share\IManager::class),
+ Server::get(IUserSession::class),
+ Server::get(IAppManager::class),
+ Server::get(ProxyMapper::class),
+ Server::get(KnownUserService::class),
+ Server::get(IConfig::class),
\OC::$server->getL10NFactory(),
'principals/'
);
-$db = \OC::$server->getDatabaseConnection();
+$db = Server::get(IDBConnection::class);
$cardDavBackend = new CardDavBackend(
$db,
$principalBackend,
- \OC::$server->getUserManager(),
- \OC::$server->get(IEventDispatcher::class),
- \OC::$server->get(\OCA\DAV\CardDAV\Sharing\Backend::class),
+ Server::get(IUserManager::class),
+ Server::get(IEventDispatcher::class),
+ Server::get(\OCA\DAV\CardDAV\Sharing\Backend::class),
);
-$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);
+$debugging = Server::get(IConfig::class)->getSystemValue('debug', false);
// Root nodes
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
$principalCollection->disableListing = !$debugging; // Disable listing
-$pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
-$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, \OC::$server->getUserSession()->getUser(), \OC::$server->get(IGroupManager::class));
+$pluginManager = new PluginManager(\OC::$server, Server::get(IAppManager::class));
+$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager, Server::get(IUserSession::class)->getUser(), Server::get(IGroupManager::class));
$addressBookRoot->disableListing = !$debugging; // Disable listing
$nodes = [
@@ -76,10 +84,10 @@ $nodes = [
// Fire up server
$server = new \Sabre\DAV\Server($nodes);
$server::$exposeVersion = false;
-$server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri());
+$server->httpRequest->setUrl(Server::get(IRequest::class)->getRequestUri());
$server->setBaseUri($baseuri);
// Add plugins
-$server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OC::$server->getL10N('dav')));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
$server->addPlugin(new Plugin());
@@ -91,10 +99,10 @@ if ($debugging) {
$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
$server->addPlugin(new ImageExportPlugin(new PhotoCache(
- \OC::$server->getAppDataDir('dav-photocache'),
- \OC::$server->get(LoggerInterface::class)
+ Server::get(IAppDataFactory::class)->get('dav-photocache'),
+ Server::get(LoggerInterface::class)
)));
-$server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->get(LoggerInterface::class)));
+$server->addPlugin(new ExceptionLoggerPlugin('carddav', Server::get(LoggerInterface::class)));
$server->addPlugin(Server::get(CardDavRateLimitingPlugin::class));
$server->addPlugin(Server::get(CardDavValidatePlugin::class));
diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php
index dc74fe214af..85dbb19d290 100644
--- a/apps/dav/appinfo/v1/publicwebdav.php
+++ b/apps/dav/appinfo/v1/publicwebdav.php
@@ -18,6 +18,15 @@ use OCP\BeforeSabrePubliclyLoadedEvent;
use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
+use OCP\Files\Mount\IMountManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IPreview;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\ITagManager;
+use OCP\IUserSession;
+use OCP\Security\Bruteforce\IThrottler;
use OCP\Server;
use Psr\Log\LoggerInterface;
@@ -27,34 +36,34 @@ $RUNTIME_APPTYPES = ['filesystem', 'authentication', 'logging'];
OC_App::loadApps($RUNTIME_APPTYPES);
OC_Util::obEnd();
-\OC::$server->getSession()->close();
+Server::get(ISession::class)->close();
// Backends
$authBackend = new LegacyPublicAuth(
- \OC::$server->getRequest(),
- \OC::$server->getShareManager(),
- \OC::$server->getSession(),
- \OC::$server->getBruteForceThrottler()
+ Server::get(IRequest::class),
+ Server::get(\OCP\Share\IManager::class),
+ Server::get(ISession::class),
+ Server::get(IThrottler::class)
);
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
/** @var IEventDispatcher $eventDispatcher */
-$eventDispatcher = \OC::$server->get(IEventDispatcher::class);
+$eventDispatcher = Server::get(IEventDispatcher::class);
$serverFactory = new ServerFactory(
- \OC::$server->getConfig(),
- \OC::$server->get(LoggerInterface::class),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserSession(),
- \OC::$server->getMountManager(),
- \OC::$server->getTagManager(),
- \OC::$server->getRequest(),
- \OC::$server->getPreviewManager(),
+ Server::get(IConfig::class),
+ Server::get(LoggerInterface::class),
+ Server::get(IDBConnection::class),
+ Server::get(IUserSession::class),
+ Server::get(IMountManager::class),
+ Server::get(ITagManager::class),
+ Server::get(IRequest::class),
+ Server::get(IPreview::class),
$eventDispatcher,
\OC::$server->getL10N('dav')
);
-$requestUri = \OC::$server->getRequest()->getRequestUri();
+$requestUri = Server::get(IRequest::class)->getRequestUri();
$linkCheckPlugin = new PublicLinkCheckPlugin();
$filesDropPlugin = new FilesDropPlugin();
@@ -62,7 +71,7 @@ $filesDropPlugin = new FilesDropPlugin();
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
$isAjax = in_array('XMLHttpRequest', explode(',', $_SERVER['HTTP_X_REQUESTED_WITH'] ?? ''));
/** @var FederatedShareProvider $shareProvider */
- $federatedShareProvider = \OC::$server->query(FederatedShareProvider::class);
+ $federatedShareProvider = Server::get(FederatedShareProvider::class);
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
throw new \Sabre\DAV\Exception\NotAuthenticated();
diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php
index 0faed7ccc94..fe47ba74652 100644
--- a/apps/dav/appinfo/v1/webdav.php
+++ b/apps/dav/appinfo/v1/webdav.php
@@ -11,7 +11,17 @@ use OCA\DAV\Connector\Sabre\BearerAuth;
use OCA\DAV\Connector\Sabre\ServerFactory;
use OCA\DAV\Events\SabrePluginAddEvent;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Mount\IMountManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IPreview;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\ITagManager;
+use OCP\IUserSession;
use OCP\SabrePluginEvent;
+use OCP\Security\Bruteforce\IThrottler;
+use OCP\Server;
use Psr\Log\LoggerInterface;
// no php execution timeout for webdav
@@ -23,39 +33,39 @@ ignore_user_abort(true);
// Turn off output buffering to prevent memory problems
\OC_Util::obEnd();
-$dispatcher = \OC::$server->get(IEventDispatcher::class);
+$dispatcher = Server::get(IEventDispatcher::class);
$serverFactory = new ServerFactory(
- \OC::$server->getConfig(),
- \OC::$server->get(LoggerInterface::class),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserSession(),
- \OC::$server->getMountManager(),
- \OC::$server->getTagManager(),
- \OC::$server->getRequest(),
- \OC::$server->getPreviewManager(),
+ Server::get(IConfig::class),
+ Server::get(LoggerInterface::class),
+ Server::get(IDBConnection::class),
+ Server::get(IUserSession::class),
+ Server::get(IMountManager::class),
+ Server::get(ITagManager::class),
+ Server::get(IRequest::class),
+ Server::get(IPreview::class),
$dispatcher,
\OC::$server->getL10N('dav')
);
// Backends
$authBackend = new Auth(
- \OC::$server->getSession(),
- \OC::$server->getUserSession(),
- \OC::$server->getRequest(),
- \OC::$server->getTwoFactorAuthManager(),
- \OC::$server->getBruteForceThrottler(),
+ Server::get(ISession::class),
+ Server::get(IUserSession::class),
+ Server::get(IRequest::class),
+ Server::get(\OC\Authentication\TwoFactorAuth\Manager::class),
+ Server::get(IThrottler::class),
'principals/'
);
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
$bearerAuthPlugin = new BearerAuth(
- \OC::$server->getUserSession(),
- \OC::$server->getSession(),
- \OC::$server->getRequest()
+ Server::get(IUserSession::class),
+ Server::get(ISession::class),
+ Server::get(IRequest::class)
);
$authPlugin->addBackend($bearerAuthPlugin);
-$requestUri = \OC::$server->getRequest()->getRequestUri();
+$requestUri = Server::get(IRequest::class)->getRequestUri();
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
// use the view for the logged in user
diff --git a/apps/dav/appinfo/v2/direct.php b/apps/dav/appinfo/v2/direct.php
index 5ba9570602a..78156317029 100644
--- a/apps/dav/appinfo/v2/direct.php
+++ b/apps/dav/appinfo/v2/direct.php
@@ -9,6 +9,10 @@ declare(strict_types=1);
use OCA\DAV\Db\DirectMapper;
use OCA\DAV\Direct\ServerFactory;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Files\IRootFolder;
+use OCP\IRequest;
+use OCP\Security\Bruteforce\IThrottler;
+use OCP\Server;
// no php execution timeout for webdav
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@@ -19,18 +23,18 @@ ignore_user_abort(true);
// Turn off output buffering to prevent memory problems
\OC_Util::obEnd();
-$requestUri = \OC::$server->getRequest()->getRequestUri();
+$requestUri = Server::get(IRequest::class)->getRequestUri();
/** @var ServerFactory $serverFactory */
-$serverFactory = \OC::$server->query(ServerFactory::class);
+$serverFactory = Server::get(ServerFactory::class);
$server = $serverFactory->createServer(
$baseuri,
$requestUri,
- \OC::$server->getRootFolder(),
- \OC::$server->query(DirectMapper::class),
- \OC::$server->query(ITimeFactory::class),
- \OC::$server->getBruteForceThrottler(),
- \OC::$server->getRequest()
+ Server::get(IRootFolder::class),
+ Server::get(DirectMapper::class),
+ Server::get(ITimeFactory::class),
+ Server::get(IThrottler::class),
+ Server::get(IRequest::class)
);
$server->exec();
diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php
index 28cfe338a93..51d26b48a5a 100644
--- a/apps/dav/appinfo/v2/remote.php
+++ b/apps/dav/appinfo/v2/remote.php
@@ -1,6 +1,7 @@
<?php
use OCA\DAV\Server;
+use OCP\IRequest;
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
@@ -16,6 +17,6 @@ ignore_user_abort(true);
// Turn off output buffering to prevent memory problems
\OC_Util::obEnd();
-$request = \OC::$server->getRequest();
+$request = \OCP\Server::get(IRequest::class);
$server = new Server($request, $baseuri);
$server->exec();
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index a01125a1103..4db58b0f137 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -83,6 +83,7 @@ use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\Events\TrustedServerRemovedEvent;
use OCP\Files\AppData\IAppDataFactory;
+use OCP\IUserSession;
use OCP\Server;
use OCP\User\Events\BeforeUserDeletedEvent;
use OCP\User\Events\BeforeUserIdUnassignedEvent;
@@ -250,7 +251,7 @@ class Application extends App implements IBootstrap {
public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void {
$cm->register(function () use ($container, $cm): void {
- $user = \OC::$server->getUserSession()->getUser();
+ $user = Server::get(IUserSession::class)->getUser();
if (!is_null($user)) {
$this->setupContactsProvider($cm, $container, $user->getUID());
} else {
@@ -279,7 +280,7 @@ class Application extends App implements IBootstrap {
public function registerCalendarManager(ICalendarManager $calendarManager,
IAppContainer $container): void {
$calendarManager->register(function () use ($container, $calendarManager): void {
- $user = \OC::$server->getUserSession()->getUser();
+ $user = Server::get(IUserSession::class)->getUser();
if ($user !== null) {
$this->setupCalendarProvider($calendarManager, $container, $user->getUID());
}
diff --git a/apps/dav/lib/Avatars/RootCollection.php b/apps/dav/lib/Avatars/RootCollection.php
index d7cdb92c6be..ec88c65793f 100644
--- a/apps/dav/lib/Avatars/RootCollection.php
+++ b/apps/dav/lib/Avatars/RootCollection.php
@@ -7,6 +7,7 @@
namespace OCA\DAV\Avatars;
use OCP\IAvatarManager;
+use OCP\Server;
use Sabre\DAVACL\AbstractPrincipalCollection;
class RootCollection extends AbstractPrincipalCollection {
@@ -22,7 +23,7 @@ class RootCollection extends AbstractPrincipalCollection {
* @return AvatarHome
*/
public function getChildForPrincipal(array $principalInfo) {
- $avatarManager = \OC::$server->get(IAvatarManager::class);
+ $avatarManager = Server::get(IAvatarManager::class);
return new AvatarHome($principalInfo, $avatarManager);
}
diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php
index c74c07bc4ab..89b78ba9007 100644
--- a/apps/dav/lib/CalDAV/CalendarHome.php
+++ b/apps/dav/lib/CalDAV/CalendarHome.php
@@ -11,8 +11,10 @@ use OCA\DAV\AppInfo\PluginManager;
use OCA\DAV\CalDAV\Integration\ExternalCalendar;
use OCA\DAV\CalDAV\Integration\ICalendarProvider;
use OCA\DAV\CalDAV\Trashbin\TrashbinHome;
+use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\CalDAV\Backend\NotificationSupport;
@@ -45,10 +47,10 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
) {
parent::__construct($caldavBackend, $principalInfo);
$this->l10n = \OC::$server->getL10N('dav');
- $this->config = \OC::$server->getConfig();
+ $this->config = Server::get(IConfig::class);
$this->pluginManager = new PluginManager(
\OC::$server,
- \OC::$server->getAppManager()
+ Server::get(IAppManager::class)
);
}
diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
index 32a3eb0ae15..3d650a4a059 100644
--- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
+++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php
@@ -20,8 +20,10 @@ use OCA\DAV\Connector\Sabre\MaintenancePlugin;
use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\RootCollection;
use OCA\Theming\ThemingDefaults;
+use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\IURLGenerator;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\VObject\ITip\Message;
@@ -42,7 +44,7 @@ class InvitationResponseServer {
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
// Add maintenance plugin
- $this->server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+ $this->server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OC::$server->getL10N('dav')));
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($baseUri);
@@ -79,13 +81,13 @@ class InvitationResponseServer {
// calendar plugins
$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(DefaultCalendarValidator::class)));
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
//$this->server->addPlugin(new \OCA\DAV\DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
$this->server->addPlugin(new PublishPlugin(
- \OC::$server->getConfig(),
- \OC::$server->getURLGenerator()
+ Server::get(IConfig::class),
+ Server::get(IURLGenerator::class)
));
// wait with registering these until auth is handled and the filesystem is setup
@@ -93,7 +95,7 @@ class InvitationResponseServer {
// register plugins from apps
$pluginManager = new PluginManager(
\OC::$server,
- \OC::$server->getAppManager()
+ Server::get(IAppManager::class)
);
foreach ($pluginManager->getAppPlugins() as $appPlugin) {
$this->server->addPlugin($appPlugin);
diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
index a5fad34e63e..265db09b061 100644
--- a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
+++ b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php
@@ -10,6 +10,7 @@ namespace OCA\DAV\CalDAV\Reminder;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException;
use OCP\AppFramework\QueryException;
+use OCP\Server;
/**
* Class NotificationProviderManager
@@ -57,7 +58,7 @@ class NotificationProviderManager {
* @throws QueryException
*/
public function registerProvider(string $providerClassName):void {
- $provider = \OC::$server->query($providerClassName);
+ $provider = Server::get($providerClassName);
if (!$provider instanceof INotificationProvider) {
throw new \InvalidArgumentException('Invalid notification provider registered');
diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php
index eaf393dec04..e29e52e77df 100644
--- a/apps/dav/lib/CardDAV/UserAddressBooks.php
+++ b/apps/dav/lib/CardDAV/UserAddressBooks.php
@@ -56,7 +56,7 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
$this->l10n = \OC::$server->getL10N('dav');
}
if ($this->config === null) {
- $this->config = \OC::$server->getConfig();
+ $this->config = Server::get(IConfig::class);
}
/** @var string|array $principal */
@@ -82,8 +82,8 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
$trustedServers = null;
$request = null;
try {
- $trustedServers = \OC::$server->get(TrustedServers::class);
- $request = \OC::$server->get(IRequest::class);
+ $trustedServers = Server::get(TrustedServers::class);
+ $request = Server::get(IRequest::class);
} catch (QueryException|NotFoundExceptionInterface|ContainerExceptionInterface $e) {
// nothing to do, the request / trusted servers don't exist
}
diff --git a/apps/dav/lib/Command/CreateCalendar.php b/apps/dav/lib/Command/CreateCalendar.php
index 5339d9d1c79..033b5f8d347 100644
--- a/apps/dav/lib/Command/CreateCalendar.php
+++ b/apps/dav/lib/Command/CreateCalendar.php
@@ -13,11 +13,15 @@ use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\CalDAV\Sharing\Backend;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
+use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Security\ISecureRandom;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -53,19 +57,19 @@ class CreateCalendar extends Command {
$principalBackend = new Principal(
$this->userManager,
$this->groupManager,
- \OC::$server->get(IAccountManager::class),
- \OC::$server->getShareManager(),
- \OC::$server->getUserSession(),
- \OC::$server->getAppManager(),
- \OC::$server->query(ProxyMapper::class),
- \OC::$server->get(KnownUserService::class),
- \OC::$server->getConfig(),
+ Server::get(IAccountManager::class),
+ Server::get(\OCP\Share\IManager::class),
+ Server::get(IUserSession::class),
+ Server::get(IAppManager::class),
+ Server::get(ProxyMapper::class),
+ Server::get(KnownUserService::class),
+ Server::get(IConfig::class),
\OC::$server->getL10NFactory(),
);
- $random = \OC::$server->getSecureRandom();
- $logger = \OC::$server->get(LoggerInterface::class);
- $dispatcher = \OC::$server->get(IEventDispatcher::class);
- $config = \OC::$server->get(IConfig::class);
+ $random = Server::get(ISecureRandom::class);
+ $logger = Server::get(LoggerInterface::class);
+ $dispatcher = Server::get(IEventDispatcher::class);
+ $config = Server::get(IConfig::class);
$name = $input->getArgument('name');
$caldav = new CalDavBackend(
$this->dbConnection,
@@ -75,7 +79,7 @@ class CreateCalendar extends Command {
$logger,
$dispatcher,
$config,
- \OC::$server->get(Backend::class),
+ Server::get(Backend::class),
);
$caldav->createCalendar("principals/users/$user", $name, []);
return self::SUCCESS;
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index 26e16a867f4..7f8fe3a84de 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -18,6 +18,7 @@ use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\ForbiddenException;
use OCP\Files\InvalidPathException;
+use OCP\Files\Mount\IMountManager;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\StorageNotAvailableException;
@@ -232,8 +233,8 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot
}
$nodes = [];
- $request = \OC::$server->get(IRequest::class);
- $l10nFactory = \OC::$server->get(IFactory::class);
+ $request = Server::get(IRequest::class);
+ $l10nFactory = Server::get(IFactory::class);
$l10n = $l10nFactory->get(Application::APP_ID);
foreach ($folderContent as $info) {
$node = $this->getChild($info->getName(), $info, $request, $l10n);
@@ -286,7 +287,7 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot
}
private function getLogger(): LoggerInterface {
- return \OC::$server->get(LoggerInterface::class);
+ return Server::get(LoggerInterface::class);
}
/**
@@ -380,7 +381,7 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot
$sourcePath = $sourceNode->getPath();
$isMovableMount = false;
- $sourceMount = \OC::$server->getMountManager()->find($this->fileView->getAbsolutePath($sourcePath));
+ $sourceMount = Server::get(IMountManager::class)->find($this->fileView->getAbsolutePath($sourcePath));
$internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
if ($sourceMount instanceof MoveableMount && $internalPath === '') {
$isMovableMount = true;
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index d6bd6369c9d..13cf8d5b0c0 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -24,6 +24,7 @@ use OCP\Files\EntityTooLargeException;
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
use OCP\Files\GenericFileException;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\InvalidContentException;
use OCP\Files\InvalidPathException;
use OCP\Files\LockNotAcquiredException;
@@ -31,6 +32,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\IWriteStreamStorage;
use OCP\Files\StorageNotAvailableException;
+use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\L10N\IFactory as IL10NFactory;
@@ -67,14 +69,14 @@ class File extends Node implements IFile {
} else {
// Querying IL10N directly results in a dependency loop
/** @var IL10NFactory $l10nFactory */
- $l10nFactory = \OC::$server->get(IL10NFactory::class);
+ $l10nFactory = Server::get(IL10NFactory::class);
$this->l10n = $l10nFactory->get(Application::APP_ID);
}
if (isset($request)) {
$this->request = $request;
} else {
- $this->request = \OC::$server->get(IRequest::class);
+ $this->request = Server::get(IRequest::class);
}
}
@@ -227,7 +229,7 @@ class File extends Node implements IFile {
} else {
$target = $partStorage->fopen($internalPartPath, 'wb');
if ($target === false) {
- \OC::$server->get(LoggerInterface::class)->error('\OC\Files\Filesystem::fopen() failed', ['app' => 'webdav']);
+ Server::get(LoggerInterface::class)->error('\OC\Files\Filesystem::fopen() failed', ['app' => 'webdav']);
// because we have no clue about the cause we can only throw back a 500/Internal Server Error
throw new Exception($this->l10n->t('Could not write file contents'));
}
@@ -274,9 +276,9 @@ class File extends Node implements IFile {
}
} catch (\Exception $e) {
if ($e instanceof LockedException) {
- \OC::$server->get(LoggerInterface::class)->debug($e->getMessage(), ['exception' => $e]);
+ Server::get(LoggerInterface::class)->debug($e->getMessage(), ['exception' => $e]);
} else {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
+ Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
}
if ($needsPartFile) {
@@ -317,7 +319,7 @@ class File extends Node implements IFile {
$renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath);
$fileExists = $storage->file_exists($internalPath);
if ($renameOkay === false || $fileExists === false) {
- \OC::$server->get(LoggerInterface::class)->error('renaming part file to final file failed $renameOkay: ' . ($renameOkay ? 'true' : 'false') . ', $fileExists: ' . ($fileExists ? 'true' : 'false') . ')', ['app' => 'webdav']);
+ Server::get(LoggerInterface::class)->error('renaming part file to final file failed $renameOkay: ' . ($renameOkay ? 'true' : 'false') . ', $fileExists: ' . ($fileExists ? 'true' : 'false') . ')', ['app' => 'webdav']);
throw new Exception($this->l10n->t('Could not rename part file to final file'));
}
} catch (ForbiddenException $ex) {
@@ -384,7 +386,7 @@ class File extends Node implements IFile {
}
private function getPartFileBasePath($path) {
- $partFileInStorage = \OC::$server->getConfig()->getSystemValue('part_file_in_storage', true);
+ $partFileInStorage = Server::get(IConfig::class)->getSystemValue('part_file_in_storage', true);
if ($partFileInStorage) {
return $path;
} else {
@@ -476,7 +478,7 @@ class File extends Node implements IFile {
// comparing current file size with the one in DB
// if different, fix DB and refresh cache.
if ($this->getSize() !== $this->fileView->filesize($this->getPath())) {
- $logger = \OC::$server->get(LoggerInterface::class);
+ $logger = Server::get(LoggerInterface::class);
$logger->warning('fixing cached size of file id=' . $this->getId());
$this->getFileInfo()->getStorage()->getUpdater()->update($this->getFileInfo()->getInternalPath());
@@ -535,7 +537,7 @@ class File extends Node implements IFile {
if ($this->request->getMethod() === 'PROPFIND') {
return $mimeType;
}
- return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType);
+ return Server::get(IMimeTypeDetector::class)->getSecureMimeType($mimeType);
}
/**
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index 4ee6283b0d2..505e6b5eda4 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -20,6 +20,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\ISharedStorage;
use OCP\Files\StorageNotAvailableException;
+use OCP\Server;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
@@ -60,14 +61,14 @@ abstract class Node implements \Sabre\DAV\INode {
if ($shareManager) {
$this->shareManager = $shareManager;
} else {
- $this->shareManager = \OC::$server->getShareManager();
+ $this->shareManager = Server::get(\OCP\Share\IManager::class);
}
if ($info instanceof Folder || $info instanceof File) {
$this->node = $info;
} else {
// The Node API assumes that the view passed doesn't have a fake root
- $rootView = \OC::$server->get(View::class);
- $root = \OC::$server->get(IRootFolder::class);
+ $rootView = Server::get(View::class);
+ $root = Server::get(IRootFolder::class);
if ($info->getType() === FileInfo::TYPE_FOLDER) {
$this->node = new Folder($root, $rootView, $this->fileView->getAbsolutePath($this->path), $info);
} else {
@@ -82,8 +83,8 @@ abstract class Node implements \Sabre\DAV\INode {
throw new \Sabre\DAV\Exception('Failed to get fileinfo for ' . $this->path);
}
$this->info = $info;
- $root = \OC::$server->get(IRootFolder::class);
- $rootView = \OC::$server->get(View::class);
+ $root = Server::get(IRootFolder::class);
+ $rootView = Server::get(View::class);
if ($this->info->getType() === FileInfo::TYPE_FOLDER) {
$this->node = new Folder($root, $rootView, $this->path, $this->info);
} else {
diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php
index dc6384daefe..f035ff8d625 100644
--- a/apps/dav/lib/Connector/Sabre/ServerFactory.php
+++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php
@@ -14,18 +14,23 @@ use OCA\DAV\DAV\CustomPropertiesBackend;
use OCA\DAV\DAV\ViewOnlyPlugin;
use OCA\DAV\Files\BrowserErrorPagePlugin;
use OCA\Theming\ThemingDefaults;
+use OCP\App\IAppManager;
+use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\IFilenameValidator;
use OCP\Files\Mount\IMountManager;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
use OCP\ITagManager;
use OCP\IUserSession;
use OCP\SabrePluginEvent;
+use OCP\SystemTag\ISystemTagManager;
+use OCP\SystemTag\ISystemTagObjectMapper;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Auth\Plugin;
@@ -141,19 +146,19 @@ class ServerFactory {
$objectTree,
$this->userSession,
$userFolder,
- \OC::$server->getShareManager()
+ \OCP\Server::get(\OCP\Share\IManager::class)
));
- $server->addPlugin(new CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
+ $server->addPlugin(new CommentPropertiesPlugin(\OCP\Server::get(ICommentsManager::class), $this->userSession));
$server->addPlugin(new FilesReportPlugin(
$objectTree,
$view,
- \OC::$server->getSystemTagManager(),
- \OC::$server->getSystemTagObjectMapper(),
- \OC::$server->getTagManager(),
+ \OCP\Server::get(ISystemTagManager::class),
+ \OCP\Server::get(ISystemTagObjectMapper::class),
+ \OCP\Server::get(ITagManager::class),
$this->userSession,
- \OC::$server->getGroupManager(),
+ \OCP\Server::get(IGroupManager::class),
$userFolder,
- \OC::$server->getAppManager()
+ \OCP\Server::get(IAppManager::class)
));
// custom properties plugin must be the last one
$server->addPlugin(
@@ -163,7 +168,7 @@ class ServerFactory {
$objectTree,
$this->databaseConnection,
$this->userSession->getUser(),
- \OC::$server->get(DefaultCalendarValidator::class),
+ \OCP\Server::get(DefaultCalendarValidator::class),
)
)
);
@@ -175,7 +180,7 @@ class ServerFactory {
$this->eventDispatcher->dispatchTyped($event);
$pluginManager = new PluginManager(
\OC::$server,
- \OC::$server->getAppManager()
+ \OCP\Server::get(IAppManager::class)
);
foreach ($pluginManager->getAppPlugins() as $appPlugin) {
$server->addPlugin($appPlugin);
diff --git a/apps/dav/lib/Files/BrowserErrorPagePlugin.php b/apps/dav/lib/Files/BrowserErrorPagePlugin.php
index 46598db2040..1491e1a89b1 100644
--- a/apps/dav/lib/Files/BrowserErrorPagePlugin.php
+++ b/apps/dav/lib/Files/BrowserErrorPagePlugin.php
@@ -77,7 +77,7 @@ class BrowserErrorPagePlugin extends ServerPlugin {
* @return bool|string
*/
public function generateBody(int $httpCode) {
- $request = \OC::$server->getRequest();
+ $request = \OCP\Server::get(IRequest::class);
$templateName = 'exception';
if ($httpCode === 403 || $httpCode === 404) {
diff --git a/apps/dav/lib/Files/RootCollection.php b/apps/dav/lib/Files/RootCollection.php
index d538d15ec1b..a11bea72c59 100644
--- a/apps/dav/lib/Files/RootCollection.php
+++ b/apps/dav/lib/Files/RootCollection.php
@@ -8,6 +8,8 @@
namespace OCA\DAV\Files;
use OCP\Files\FileInfo;
+use OCP\IUserSession;
+use OCP\Server;
use Sabre\DAV\INode;
use Sabre\DAV\SimpleCollection;
use Sabre\DAVACL\AbstractPrincipalCollection;
@@ -26,7 +28,7 @@ class RootCollection extends AbstractPrincipalCollection {
*/
public function getChildForPrincipal(array $principalInfo) {
[,$name] = \Sabre\Uri\split($principalInfo['uri']);
- $user = \OC::$server->getUserSession()->getUser();
+ $user = Server::get(IUserSession::class)->getUser();
if (is_null($user) || $name !== $user->getUID()) {
// a user is only allowed to see their own home contents, so in case another collection
// is accessed, we return a simple empty collection for now
diff --git a/apps/dav/lib/Listener/UserEventsListener.php b/apps/dav/lib/Listener/UserEventsListener.php
index c8811f26d9b..8f3997a51ef 100644
--- a/apps/dav/lib/Listener/UserEventsListener.php
+++ b/apps/dav/lib/Listener/UserEventsListener.php
@@ -17,6 +17,7 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Server;
use OCP\User\Events\BeforeUserDeletedEvent;
use OCP\User\Events\BeforeUserIdUnassignedEvent;
use OCP\User\Events\UserChangedEvent;
@@ -135,7 +136,7 @@ class UserEventsListener implements IEventListener {
'components' => 'VEVENT'
]);
} catch (\Exception $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
+ Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
}
}
if ($this->cardDav->getAddressBooksForUserCount($principal) === 0) {
@@ -144,7 +145,7 @@ class UserEventsListener implements IEventListener {
'{DAV:}displayname' => CardDavBackend::PERSONAL_ADDRESSBOOK_NAME,
]);
} catch (\Exception $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
+ Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
}
}
}
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index 751ab17bb7a..e14d07943e7 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -30,38 +30,46 @@ use OCA\DAV\Upload\CleanupService;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IGroupManager;
+use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Security\ISecureRandom;
use OCP\Server;
+use OCP\SystemTag\ISystemTagManager;
+use OCP\SystemTag\ISystemTagObjectMapper;
use Psr\Log\LoggerInterface;
use Sabre\DAV\SimpleCollection;
class RootCollection extends SimpleCollection {
public function __construct() {
$l10n = \OC::$server->getL10N('dav');
- $random = \OC::$server->getSecureRandom();
- $logger = \OC::$server->get(LoggerInterface::class);
- $userManager = \OC::$server->getUserManager();
- $userSession = \OC::$server->getUserSession();
- $groupManager = \OC::$server->getGroupManager();
- $shareManager = \OC::$server->getShareManager();
- $db = \OC::$server->getDatabaseConnection();
- $dispatcher = \OC::$server->get(IEventDispatcher::class);
- $config = \OC::$server->get(IConfig::class);
- $proxyMapper = \OC::$server->query(ProxyMapper::class);
+ $random = Server::get(ISecureRandom::class);
+ $logger = Server::get(LoggerInterface::class);
+ $userManager = Server::get(IUserManager::class);
+ $userSession = Server::get(IUserSession::class);
+ $groupManager = Server::get(IGroupManager::class);
+ $shareManager = Server::get(\OCP\Share\IManager::class);
+ $db = Server::get(IDBConnection::class);
+ $dispatcher = Server::get(IEventDispatcher::class);
+ $config = Server::get(IConfig::class);
+ $proxyMapper = Server::get(ProxyMapper::class);
$rootFolder = Server::get(IRootFolder::class);
$userPrincipalBackend = new Principal(
$userManager,
$groupManager,
- \OC::$server->get(IAccountManager::class),
+ Server::get(IAccountManager::class),
$shareManager,
- \OC::$server->getUserSession(),
- \OC::$server->getAppManager(),
+ Server::get(IUserSession::class),
+ Server::get(IAppManager::class),
$proxyMapper,
- \OC::$server->get(KnownUserService::class),
- \OC::$server->getConfig(),
+ Server::get(KnownUserService::class),
+ Server::get(IConfig::class),
\OC::$server->getL10NFactory()
);
@@ -80,7 +88,7 @@ class RootCollection extends SimpleCollection {
$systemPrincipals->disableListing = $disableListing;
$calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
$calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
- $calendarSharingBackend = \OC::$server->get(Backend::class);
+ $calendarSharingBackend = Server::get(Backend::class);
$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
$filesCollection->disableListing = $disableListing;
@@ -107,25 +115,25 @@ class RootCollection extends SimpleCollection {
$systemTagCollection = Server::get(SystemTagsByIdCollection::class);
$systemTagRelationsCollection = new SystemTagsRelationsCollection(
- \OC::$server->getSystemTagManager(),
- \OC::$server->getSystemTagObjectMapper(),
- \OC::$server->getUserSession(),
+ Server::get(ISystemTagManager::class),
+ Server::get(ISystemTagObjectMapper::class),
+ Server::get(IUserSession::class),
$groupManager,
$dispatcher,
$rootFolder,
);
$systemTagInUseCollection = Server::get(SystemTagsInUseCollection::class);
$commentsCollection = new Comments\RootCollection(
- \OC::$server->getCommentsManager(),
+ Server::get(ICommentsManager::class),
$userManager,
- \OC::$server->getUserSession(),
+ Server::get(IUserSession::class),
$dispatcher,
$logger
);
- $contactsSharingBackend = \OC::$server->get(\OCA\DAV\CardDAV\Sharing\Backend::class);
+ $contactsSharingBackend = Server::get(\OCA\DAV\CardDAV\Sharing\Backend::class);
- $pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class));
+ $pluginManager = new PluginManager(\OC::$server, Server::get(IAppManager::class));
$usersCardDavBackend = new CardDavBackend(
$db,
$userPrincipalBackend,
@@ -149,14 +157,14 @@ class RootCollection extends SimpleCollection {
$uploadCollection = new Upload\RootCollection(
$userPrincipalBackend,
'principals/users',
- \OC::$server->query(CleanupService::class));
+ Server::get(CleanupService::class));
$uploadCollection->disableListing = $disableListing;
$avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
$avatarCollection->disableListing = $disableListing;
$appleProvisioning = new AppleProvisioningNode(
- \OC::$server->query(ITimeFactory::class));
+ Server::get(ITimeFactory::class));
$children = [
new SimpleCollection('principals', [
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index f07927ff0f9..a14b49c178e 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -64,22 +64,34 @@ use OCA\DAV\SystemTag\SystemTagPlugin;
use OCA\DAV\Upload\ChunkingPlugin;
use OCA\DAV\Upload\ChunkingV2Plugin;
use OCA\Theming\ThemingDefaults;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Comments\ICommentsManager;
use OCP\Defaults;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\IFilenameValidator;
+use OCP\Files\IRootFolder;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IGroupManager;
use OCP\IPreview;
use OCP\IRequest;
+use OCP\ISession;
+use OCP\ITagManager;
+use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Mail\IMailer;
use OCP\Profiler\IProfiler;
use OCP\SabrePluginEvent;
+use OCP\Security\Bruteforce\IThrottler;
+use OCP\SystemTag\ISystemTagManager;
+use OCP\SystemTag\ISystemTagObjectMapper;
use Psr\Log\LoggerInterface;
use Sabre\CardDAV\VCFExportPlugin;
use Sabre\DAV\Auth\Plugin;
@@ -94,10 +106,10 @@ class Server {
private IRequest $request,
private string $baseUri,
) {
- $this->profiler = \OC::$server->get(IProfiler::class);
+ $this->profiler = \OCP\Server::get(IProfiler::class);
if ($this->profiler->isEnabled()) {
/** @var IEventLogger $eventLogger */
- $eventLogger = \OC::$server->get(IEventLogger::class);
+ $eventLogger = \OCP\Server::get(IEventLogger::class);
$eventLogger->start('runtime', 'DAV Runtime');
}
@@ -108,17 +120,17 @@ class Server {
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
// Add maintenance plugin
- $this->server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
+ $this->server->addPlugin(new MaintenancePlugin(\OCP\Server::get(IConfig::class), \OC::$server->getL10N('dav')));
$this->server->addPlugin(new AppleQuirksPlugin());
// Backends
$authBackend = new Auth(
- \OC::$server->getSession(),
- \OC::$server->getUserSession(),
- \OC::$server->getRequest(),
- \OC::$server->getTwoFactorAuthManager(),
- \OC::$server->getBruteForceThrottler()
+ \OCP\Server::get(ISession::class),
+ \OCP\Server::get(IUserSession::class),
+ \OCP\Server::get(IRequest::class),
+ \OCP\Server::get(\OC\Authentication\TwoFactorAuth\Manager::class),
+ \OCP\Server::get(IThrottler::class)
);
// Set URL explicitly due to reverse-proxy situations
@@ -143,16 +155,16 @@ class Server {
$eventDispatcher->dispatchTyped($newAuthEvent);
$bearerAuthBackend = new BearerAuth(
- \OC::$server->getUserSession(),
- \OC::$server->getSession(),
- \OC::$server->getRequest()
+ \OCP\Server::get(IUserSession::class),
+ \OCP\Server::get(ISession::class),
+ \OCP\Server::get(IRequest::class)
);
$authPlugin->addBackend($bearerAuthBackend);
// because we are throwing exceptions this plugin has to be the last one
$authPlugin->addBackend($authBackend);
// debugging
- if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
+ if (\OCP\Server::get(IConfig::class)->getSystemValue('debug', false)) {
$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
} else {
$this->server->addPlugin(new DummyGetResponsePlugin());
@@ -174,21 +186,21 @@ class Server {
// calendar plugins
if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) {
- $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig()));
+ $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OCP\Server::get(IRequest::class), \OCP\Server::get(IConfig::class)));
$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
- $this->server->addPlugin(new ICSExportPlugin(\OC::$server->getConfig(), $logger));
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(DefaultCalendarValidator::class)));
+ $this->server->addPlugin(new ICSExportPlugin(\OCP\Server::get(IConfig::class), $logger));
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OCP\Server::get(IConfig::class), \OCP\Server::get(LoggerInterface::class), \OCP\Server::get(DefaultCalendarValidator::class)));
- $this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class));
+ $this->server->addPlugin(\OCP\Server::get(\OCA\DAV\CalDAV\Trashbin\Plugin::class));
$this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($this->request));
- if (\OC::$server->getConfig()->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes') === 'yes') {
+ if (\OCP\Server::get(IConfig::class)->getAppValue('dav', 'allow_calendar_link_subscriptions', 'yes') === 'yes') {
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
}
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
$this->server->addPlugin(new PublishPlugin(
- \OC::$server->getConfig(),
- \OC::$server->getURLGenerator()
+ \OCP\Server::get(IConfig::class),
+ \OCP\Server::get(IURLGenerator::class)
));
$this->server->addPlugin(\OCP\Server::get(RateLimitingPlugin::class));
@@ -197,13 +209,13 @@ class Server {
// addressbook plugins
if ($this->requestIsForSubtree(['addressbooks', 'principals'])) {
- $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig()));
+ $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OCP\Server::get(IRequest::class), \OCP\Server::get(IConfig::class)));
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
$this->server->addPlugin(new VCFExportPlugin());
$this->server->addPlugin(new MultiGetExportPlugin());
$this->server->addPlugin(new HasPhotoPlugin());
$this->server->addPlugin(new ImageExportPlugin(new PhotoCache(
- \OC::$server->getAppDataDir('dav-photocache'),
+ \OCP\Server::get(IAppDataFactory::class)->get('dav-photocache'),
$logger)
));
@@ -212,16 +224,16 @@ class Server {
}
// system tags plugins
- $this->server->addPlugin(\OC::$server->get(SystemTagPlugin::class));
+ $this->server->addPlugin(\OCP\Server::get(SystemTagPlugin::class));
// comments plugin
$this->server->addPlugin(new CommentsPlugin(
- \OC::$server->getCommentsManager(),
- \OC::$server->getUserSession()
+ \OCP\Server::get(ICommentsManager::class),
+ \OCP\Server::get(IUserSession::class)
));
$this->server->addPlugin(new CopyEtagHeaderPlugin());
- $this->server->addPlugin(new RequestIdHeaderPlugin(\OC::$server->get(IRequest::class)));
+ $this->server->addPlugin(new RequestIdHeaderPlugin(\OCP\Server::get(IRequest::class)));
$this->server->addPlugin(new ChunkingV2Plugin(\OCP\Server::get(ICacheFactory::class)));
$this->server->addPlugin(new ChunkingPlugin());
$this->server->addPlugin(new ZipFolderPlugin(
@@ -261,7 +273,7 @@ class Server {
));
// custom properties plugin must be the last one
- $userSession = \OC::$server->getUserSession();
+ $userSession = \OCP\Server::get(IUserSession::class);
$user = $userSession->getUser();
if ($user !== null) {
$view = Filesystem::getView();
@@ -285,9 +297,9 @@ class Server {
new CustomPropertiesBackend(
$this->server,
$this->server->tree,
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserSession()->getUser(),
- \OC::$server->get(DefaultCalendarValidator::class),
+ \OCP\Server::get(IDBConnection::class),
+ \OCP\Server::get(IUserSession::class)->getUser(),
+ \OCP\Server::get(DefaultCalendarValidator::class),
)
)
);
@@ -297,7 +309,7 @@ class Server {
}
$this->server->addPlugin(
new TagsPlugin(
- $this->server->tree, \OC::$server->getTagManager(), \OC::$server->get(IEventDispatcher::class), \OC::$server->get(IUserSession::class)
+ $this->server->tree, \OCP\Server::get(ITagManager::class), \OCP\Server::get(IEventDispatcher::class), \OCP\Server::get(IUserSession::class)
)
);
@@ -311,20 +323,20 @@ class Server {
$shareManager,
));
$this->server->addPlugin(new CommentPropertiesPlugin(
- \OC::$server->getCommentsManager(),
+ \OCP\Server::get(ICommentsManager::class),
$userSession
));
- if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
+ if (\OCP\Server::get(IConfig::class)->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
$this->server->addPlugin(new IMipPlugin(
- \OC::$server->get(IAppConfig::class),
- \OC::$server->get(IMailer::class),
- \OC::$server->get(LoggerInterface::class),
- \OC::$server->get(ITimeFactory::class),
- \OC::$server->get(Defaults::class),
+ \OCP\Server::get(IAppConfig::class),
+ \OCP\Server::get(IMailer::class),
+ \OCP\Server::get(LoggerInterface::class),
+ \OCP\Server::get(ITimeFactory::class),
+ \OCP\Server::get(Defaults::class),
$userSession,
- \OC::$server->get(IMipService::class),
- \OC::$server->get(EventComparisonService::class),
- \OC::$server->get(\OCP\Mail\Provider\IManager::class)
+ \OCP\Server::get(IMipService::class),
+ \OCP\Server::get(EventComparisonService::class),
+ \OCP\Server::get(\OCP\Mail\Provider\IManager::class)
));
}
$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
@@ -332,18 +344,18 @@ class Server {
$this->server->addPlugin(new FilesReportPlugin(
$this->server->tree,
$view,
- \OC::$server->getSystemTagManager(),
- \OC::$server->getSystemTagObjectMapper(),
- \OC::$server->getTagManager(),
+ \OCP\Server::get(ISystemTagManager::class),
+ \OCP\Server::get(ISystemTagObjectMapper::class),
+ \OCP\Server::get(ITagManager::class),
$userSession,
- \OC::$server->getGroupManager(),
+ \OCP\Server::get(IGroupManager::class),
$userFolder,
- \OC::$server->getAppManager()
+ \OCP\Server::get(IAppManager::class)
));
$lazySearchBackend->setBackend(new FileSearchBackend(
$this->server->tree,
$user,
- \OC::$server->getRootFolder(),
+ \OCP\Server::get(IRootFolder::class),
$shareManager,
$view,
\OCP\Server::get(IFilesMetadataManager::class)
@@ -356,15 +368,15 @@ class Server {
);
}
$this->server->addPlugin(new EnablePlugin(
- \OC::$server->getConfig(),
- \OC::$server->query(BirthdayService::class),
+ \OCP\Server::get(IConfig::class),
+ \OCP\Server::get(BirthdayService::class),
$user
));
$this->server->addPlugin(new AppleProvisioningPlugin(
- \OC::$server->getUserSession(),
- \OC::$server->getURLGenerator(),
- \OC::$server->getThemingDefaults(),
- \OC::$server->getRequest(),
+ \OCP\Server::get(IUserSession::class),
+ \OCP\Server::get(IURLGenerator::class),
+ \OCP\Server::get(ThemingDefaults::class),
+ \OCP\Server::get(IRequest::class),
\OC::$server->getL10N('dav'),
function () {
return UUIDUtil::getUUID();
@@ -375,7 +387,7 @@ class Server {
// register plugins from apps
$pluginManager = new PluginManager(
\OC::$server,
- \OC::$server->getAppManager()
+ \OCP\Server::get(IAppManager::class)
);
foreach ($pluginManager->getAppPlugins() as $appPlugin) {
$this->server->addPlugin($appPlugin);
@@ -392,13 +404,13 @@ class Server {
public function exec() {
/** @var IEventLogger $eventLogger */
- $eventLogger = \OC::$server->get(IEventLogger::class);
+ $eventLogger = \OCP\Server::get(IEventLogger::class);
$eventLogger->start('dav_server_exec', '');
$this->server->start();
$eventLogger->end('dav_server_exec');
if ($this->profiler->isEnabled()) {
$eventLogger->end('runtime');
- $profile = $this->profiler->collect(\OC::$server->get(IRequest::class), new Response());
+ $profile = $this->profiler->collect(\OCP\Server::get(IRequest::class), new Response());
$this->profiler->saveProfile($profile);
}
}
diff --git a/apps/dav/lib/Upload/UploadFolder.php b/apps/dav/lib/Upload/UploadFolder.php
index 8ea0591ab16..57e95d2b17b 100644
--- a/apps/dav/lib/Upload/UploadFolder.php
+++ b/apps/dav/lib/Upload/UploadFolder.php
@@ -11,6 +11,8 @@ use OC\Files\ObjectStore\ObjectStoreStorage;
use OCA\DAV\Connector\Sabre\Directory;
use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
use OCP\Files\Storage\IStorage;
+use OCP\ICacheFactory;
+use OCP\Server;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\ICollection;
@@ -60,7 +62,7 @@ class UploadFolder implements ICollection {
/** @var ObjectStoreStorage $storage */
$objectStore = $this->storage->getObjectStore();
if ($objectStore instanceof IObjectStoreMultiPartUpload) {
- $cache = \OC::$server->getMemCacheFactory()->createDistributed(ChunkingV2Plugin::CACHE_KEY);
+ $cache = Server::get(ICacheFactory::class)->createDistributed(ChunkingV2Plugin::CACHE_KEY);
$uploadSession = $cache->get($this->getName());
if ($uploadSession) {
$uploadId = $uploadSession[ChunkingV2Plugin::UPLOAD_ID];
diff --git a/apps/dav/lib/Upload/UploadHome.php b/apps/dav/lib/Upload/UploadHome.php
index 739c38feb30..3a8e13eb02d 100644
--- a/apps/dav/lib/Upload/UploadHome.php
+++ b/apps/dav/lib/Upload/UploadHome.php
@@ -10,6 +10,8 @@ namespace OCA\DAV\Upload;
use OC\Files\Filesystem;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
+use OCP\IUserSession;
+use OCP\Server;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\ICollection;
@@ -73,7 +75,7 @@ class UploadHome implements ICollection {
private function getView() {
$rootView = new View();
- $user = \OC::$server->getUserSession()->getUser();
+ $user = Server::get(IUserSession::class)->getUser();
Filesystem::initMountPoints($user->getUID());
if (!$rootView->file_exists('/' . $user->getUID() . '/uploads')) {
$rootView->mkdir('/' . $user->getUID() . '/uploads');
diff --git a/apps/dav/templates/settings-admin-caldav.php b/apps/dav/templates/settings-admin-caldav.php
index d0bc92bc965..636114ced75 100644
--- a/apps/dav/templates/settings-admin-caldav.php
+++ b/apps/dav/templates/settings-admin-caldav.php
@@ -4,7 +4,7 @@
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-script('dav', 'settings-admin-caldav');
+\OCP\Util::addScript('dav', 'settings-admin-caldav', 'core');
?>
diff --git a/apps/dav/templates/settings-personal-availability.php b/apps/dav/templates/settings-personal-availability.php
index da0b2d9f104..f1c049392a3 100644
--- a/apps/dav/templates/settings-personal-availability.php
+++ b/apps/dav/templates/settings-personal-availability.php
@@ -4,7 +4,7 @@
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-script('dav', 'settings-personal-availability');
+\OCP\Util::addScript('dav', 'settings-personal-availability', 'core');
?>
diff --git a/apps/dav/tests/integration/Db/PropertyMapperTest.php b/apps/dav/tests/integration/Db/PropertyMapperTest.php
index 054acedb664..9bd47a82d35 100644
--- a/apps/dav/tests/integration/Db/PropertyMapperTest.php
+++ b/apps/dav/tests/integration/Db/PropertyMapperTest.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace OCA\DAV\Tests\integration\Db;
use OCA\DAV\Db\PropertyMapper;
+use OCP\Server;
use Test\TestCase;
/**
@@ -23,7 +24,7 @@ class PropertyMapperTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->mapper = \OC::$server->get(PropertyMapper::class);
+ $this->mapper = Server::get(PropertyMapper::class);
}
public function testFindNonExistent(): void {
diff --git a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
index 7e30ec3d2fe..ce3871aa400 100644
--- a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
@@ -14,8 +14,10 @@ use OCA\DAV\BackgroundJob\UserStatusAutomation;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Server;
use OCP\User\IAvailabilityCoordinator;
use OCP\UserStatus\IManager;
use OCP\UserStatus\IUserStatus;
@@ -53,7 +55,7 @@ class UserStatusAutomationTest extends TestCase {
if (empty($methods)) {
return new UserStatusAutomation(
$this->time,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->jobList,
$this->logger,
$this->statusManager,
@@ -66,7 +68,7 @@ class UserStatusAutomationTest extends TestCase {
return $this->getMockBuilder(UserStatusAutomation::class)
->setConstructorArgs([
$this->time,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->jobList,
$this->logger,
$this->statusManager,
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
index 946a2328bf8..c1d8e8609b6 100644
--- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
+++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
@@ -25,6 +25,7 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
+use OCP\Server;
use OCP\Share\IManager as ShareManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
@@ -87,8 +88,8 @@ abstract class AbstractCalDavBackend extends TestCase {
->withAnyParameters()
->willReturn([self::UNIT_TEST_GROUP, self::UNIT_TEST_GROUP2]);
- $this->db = \OC::$server->getDatabaseConnection();
- $this->random = \OC::$server->getSecureRandom();
+ $this->db = Server::get(IDBConnection::class);
+ $this->random = Server::get(ISecureRandom::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->config = $this->createMock(IConfig::class);
$this->sharingBackend = new SharingBackend(
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php
index fcfd1f81517..392759206ed 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php
@@ -8,6 +8,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\Activity\Filter;
use OCA\DAV\CalDAV\Activity\Filter\Calendar;
use OCA\DAV\CalDAV\Activity\Filter\Todo;
use OCP\Activity\IFilter;
+use OCP\Server;
use Test\TestCase;
/**
@@ -26,7 +27,7 @@ class GenericTest extends TestCase {
* @param string $filterClass
*/
public function testImplementsInterface($filterClass): void {
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertInstanceOf(IFilter::class, $filter);
}
@@ -36,7 +37,7 @@ class GenericTest extends TestCase {
*/
public function testGetIdentifier($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertIsString($filter->getIdentifier());
}
@@ -46,7 +47,7 @@ class GenericTest extends TestCase {
*/
public function testGetName($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertIsString($filter->getName());
}
@@ -56,7 +57,7 @@ class GenericTest extends TestCase {
*/
public function testGetPriority($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$priority = $filter->getPriority();
$this->assertIsInt($filter->getPriority());
$this->assertGreaterThanOrEqual(0, $priority);
@@ -69,7 +70,7 @@ class GenericTest extends TestCase {
*/
public function testGetIcon($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertIsString($filter->getIcon());
$this->assertStringStartsWith('http', $filter->getIcon());
}
@@ -80,7 +81,7 @@ class GenericTest extends TestCase {
*/
public function testFilterTypes($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertIsArray($filter->filterTypes([]));
}
@@ -90,7 +91,7 @@ class GenericTest extends TestCase {
*/
public function testAllowedApps($filterClass): void {
/** @var IFilter $filter */
- $filter = \OC::$server->query($filterClass);
+ $filter = Server::get($filterClass);
$this->assertIsArray($filter->allowedApps());
}
}
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php
index 678b815999c..42b565b9d8b 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php
@@ -9,6 +9,7 @@ use OCA\DAV\CalDAV\Activity\Setting\Calendar;
use OCA\DAV\CalDAV\Activity\Setting\Event;
use OCA\DAV\CalDAV\Activity\Setting\Todo;
use OCP\Activity\ISetting;
+use OCP\Server;
use Test\TestCase;
class GenericTest extends TestCase {
@@ -25,7 +26,7 @@ class GenericTest extends TestCase {
* @param string $settingClass
*/
public function testImplementsInterface($settingClass): void {
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertInstanceOf(ISetting::class, $setting);
}
@@ -35,7 +36,7 @@ class GenericTest extends TestCase {
*/
public function testGetIdentifier($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsString($setting->getIdentifier());
}
@@ -45,7 +46,7 @@ class GenericTest extends TestCase {
*/
public function testGetName($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsString($setting->getName());
}
@@ -55,7 +56,7 @@ class GenericTest extends TestCase {
*/
public function testGetPriority($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$priority = $setting->getPriority();
$this->assertIsInt($setting->getPriority());
$this->assertGreaterThanOrEqual(0, $priority);
@@ -68,7 +69,7 @@ class GenericTest extends TestCase {
*/
public function testCanChangeStream($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsBool($setting->canChangeStream());
}
@@ -78,7 +79,7 @@ class GenericTest extends TestCase {
*/
public function testIsDefaultEnabledStream($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsBool($setting->isDefaultEnabledStream());
}
@@ -88,7 +89,7 @@ class GenericTest extends TestCase {
*/
public function testCanChangeMail($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsBool($setting->canChangeMail());
}
@@ -98,7 +99,7 @@ class GenericTest extends TestCase {
*/
public function testIsDefaultEnabledMail($settingClass): void {
/** @var ISetting $setting */
- $setting = \OC::$server->query($settingClass);
+ $setting = Server::get($settingClass);
$this->assertIsBool($setting->isDefaultEnabledMail());
}
}
diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
index 4333754222b..075681eff7f 100644
--- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
+++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
@@ -12,10 +12,12 @@ use OCA\DAV\CalDAV\PublicCalendarRoot;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -51,11 +53,11 @@ class PublicCalendarRootTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $db = \OC::$server->getDatabaseConnection();
+ $db = Server::get(IDBConnection::class);
$this->principal = $this->createMock('OCA\DAV\Connector\Sabre\Principal');
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
- $this->random = \OC::$server->getSecureRandom();
+ $this->random = Server::get(ISecureRandom::class);
$this->logger = $this->createMock(LoggerInterface::class);
$dispatcher = $this->createMock(IEventDispatcher::class);
$config = $this->createMock(IConfig::class);
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
index 8f89283e94d..1516d41ea39 100644
--- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
+++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
@@ -27,6 +27,7 @@ use OCP\IL10N;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
+use OCP\Server;
use OCP\Share\IManager as ShareManager;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\BadRequest;
@@ -133,7 +134,7 @@ class CardDavBackendTest extends TestCase {
->willReturn([self::UNIT_TEST_GROUP]);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
- $this->db = \OC::$server->getDatabaseConnection();
+ $this->db = Server::get(IDBConnection::class);
$this->sharingBackend = new Backend($this->userManager,
$this->groupManager,
$this->principal,
diff --git a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
index 3c597e22a95..f2346c211ce 100644
--- a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
+++ b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
@@ -9,7 +9,9 @@ namespace OCA\DAV\Tests\Unit\Command;
use OCA\DAV\Command\RemoveInvalidShares;
use OCA\DAV\Connector\Sabre\Principal;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
+use OCP\Server;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -23,7 +25,7 @@ use Test\TestCase;
class RemoveInvalidSharesTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $db = \OC::$server->getDatabaseConnection();
+ $db = Server::get(IDBConnection::class);
$db->insertIfNotExist('*PREFIX*dav_shares', [
'principaluri' => 'principal:unknown',
@@ -34,7 +36,7 @@ class RemoveInvalidSharesTest extends TestCase {
}
public function test(): void {
- $db = \OC::$server->getDatabaseConnection();
+ $db = Server::get(IDBConnection::class);
/** @var Principal | \PHPUnit\Framework\MockObject\MockObject $principal */
$principal = $this->createMock(Principal::class);
diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
index 72d5e7198a3..eb3f291e9c0 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
@@ -11,7 +11,9 @@ use OCA\DAV\CalDAV\DefaultCalendarValidator;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
use OCA\DAV\DAV\CustomPropertiesBackend;
+use OCP\IDBConnection;
use OCP\IUser;
+use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Sabre\DAV\Tree;
@@ -68,14 +70,14 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
$this->plugin = new CustomPropertiesBackend(
$this->server,
$this->tree,
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->user,
$this->defaultCalendarValidator,
);
}
protected function tearDown(): void {
- $connection = \OC::$server->getDatabaseConnection();
+ $connection = Server::get(IDBConnection::class);
$deleteStatement = $connection->prepare(
'DELETE FROM `*PREFIX*properties`' .
' WHERE `userid` = ?'
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php
index df48cd61114..836766b366d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/Auth.php
@@ -7,6 +7,8 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
+use OCP\IUserSession;
+use OCP\Server;
use Sabre\DAV\Auth\Backend\BackendInterface;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -53,7 +55,7 @@ class Auth implements BackendInterface {
* @return array
*/
public function check(RequestInterface $request, ResponseInterface $response) {
- $userSession = \OC::$server->getUserSession();
+ $userSession = Server::get(IUserSession::class);
$result = $userSession->login($this->user, $this->password);
if ($result) {
//we need to pass the user name, which may differ from login name
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php
index cbaa0c3101b..92d89d7753a 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php
@@ -8,6 +8,9 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OC\Files\View;
+use OCP\IConfig;
+use OCP\ITempManager;
+use OCP\Server;
use Test\Traits\EncryptionTrait;
/**
@@ -22,10 +25,10 @@ class EncryptionMasterKeyUploadTest extends UploadTest {
protected function setupUser($name, $password) {
$this->createUser($name, $password);
- $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
+ $tmpFolder = Server::get(ITempManager::class)->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
// we use the master key
- \OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '1');
+ Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '1');
$this->setupForUser($name, $password);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php
index f830c54fd0d..935ef6d9464 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php
@@ -8,6 +8,9 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OC\Files\View;
+use OCP\IConfig;
+use OCP\ITempManager;
+use OCP\Server;
use Test\Traits\EncryptionTrait;
/**
@@ -22,10 +25,10 @@ class EncryptionUploadTest extends UploadTest {
protected function setupUser($name, $password) {
$this->createUser($name, $password);
- $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
+ $tmpFolder = Server::get(ITempManager::class)->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
// we use per-user keys
- \OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '0');
+ Server::get(IConfig::class)->setAppValue('encryption', 'useMasterKey', '0');
$this->setupForUser($name, $password);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
index 11a44f26942..5f3dc6f4e32 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
@@ -9,6 +9,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OC\AllConfig;
use OCP\IConfig;
+use OCP\Server;
/**
* Class PartFileInRootUploadTest
@@ -19,7 +20,7 @@ use OCP\IConfig;
*/
class PartFileInRootUploadTest extends UploadTest {
protected function setUp(): void {
- $config = \OC::$server->getConfig();
+ $config = Server::get(IConfig::class);
$mockConfig = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
index 4085bc93c78..a04aedb4e57 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
@@ -11,9 +11,15 @@ use OC\Files\View;
use OCA\DAV\Connector\Sabre\Server;
use OCA\DAV\Connector\Sabre\ServerFactory;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Mount\IMountManager;
use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IPreview;
use OCP\IRequest;
use OCP\IRequestId;
+use OCP\ITagManager;
+use OCP\ITempManager;
+use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use Sabre\HTTP\Request;
use Test\TestCase;
@@ -40,24 +46,24 @@ abstract class RequestTestCase extends TestCase {
parent::setUp();
$this->serverFactory = new ServerFactory(
- \OC::$server->getConfig(),
- \OC::$server->get(LoggerInterface::class),
- \OC::$server->getDatabaseConnection(),
- \OC::$server->getUserSession(),
- \OC::$server->getMountManager(),
- \OC::$server->getTagManager(),
+ \OCP\Server::get(IConfig::class),
+ \OCP\Server::get(LoggerInterface::class),
+ \OCP\Server::get(IDBConnection::class),
+ \OCP\Server::get(IUserSession::class),
+ \OCP\Server::get(IMountManager::class),
+ \OCP\Server::get(ITagManager::class),
$this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock(),
- \OC::$server->getPreviewManager(),
- \OC::$server->get(IEventDispatcher::class),
+ \OCP\Server::get(IPreview::class),
+ \OCP\Server::get(IEventDispatcher::class),
\OC::$server->getL10N('dav')
);
}
protected function setupUser($name, $password) {
$this->createUser($name, $password);
- $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
+ $tmpFolder = \OCP\Server::get(ITempManager::class)->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->loginAsUser($name);
return new View('/' . $name . '/files');
@@ -79,7 +85,7 @@ abstract class RequestTestCase extends TestCase {
$body = $this->getStream($body);
}
$this->logout();
- $exceptionPlugin = new ExceptionPlugin('webdav', \OC::$server->get(LoggerInterface::class));
+ $exceptionPlugin = new ExceptionPlugin('webdav', \OCP\Server::get(LoggerInterface::class));
$server = $this->getSabreServer($view, $user, $password, $exceptionPlugin);
$request = new Request($method, $url, $headers, $body);
diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
index fa71fd8016b..5590e8c1ff0 100644
--- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
@@ -57,7 +57,7 @@ class CustomPropertiesBackendTest extends TestCase {
$this->user->method('getUID')
->with()
->willReturn('dummy_user_42');
- $this->dbConnection = \OC::$server->getDatabaseConnection();
+ $this->dbConnection = \OCP\Server::get(IDBConnection::class);
$this->defaultCalendarValidator = $this->createMock(DefaultCalendarValidator::class);
$this->backend = new CustomPropertiesBackend(
diff --git a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
index 1cebf199d29..be2c64c47a4 100644
--- a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
+++ b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
@@ -7,7 +7,9 @@ namespace OCA\DAV\Tests\Unit\DAV\Migration;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Migration\CalDAVRemoveEmptyValue;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Sabre\VObject\InvalidDataException;
use Test\TestCase;
@@ -83,7 +85,7 @@ END:VCALENDAR';
/** @var CalDAVRemoveEmptyValue|\PHPUnit\Framework\MockObject\MockObject $step */
$step = $this->getMockBuilder(CalDAVRemoveEmptyValue::class)
->setConstructorArgs([
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->backend,
$this->logger
])
@@ -107,7 +109,7 @@ END:VCALENDAR';
/** @var CalDAVRemoveEmptyValue|\PHPUnit\Framework\MockObject\MockObject $step */
$step = $this->getMockBuilder(CalDAVRemoveEmptyValue::class)
->setConstructorArgs([
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->backend,
$this->logger
])
@@ -150,7 +152,7 @@ END:VCALENDAR';
/** @var CalDAVRemoveEmptyValue|\PHPUnit\Framework\MockObject\MockObject $step */
$step = $this->getMockBuilder(CalDAVRemoveEmptyValue::class)
->setConstructorArgs([
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->backend,
$this->logger
])
@@ -192,7 +194,7 @@ END:VCALENDAR';
/** @var CalDAVRemoveEmptyValue|\PHPUnit\Framework\MockObject\MockObject $step */
$step = $this->getMockBuilder(CalDAVRemoveEmptyValue::class)
->setConstructorArgs([
- \OC::$server->getDatabaseConnection(),
+ Server::get(IDBConnection::class),
$this->backend,
$this->logger
])