aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/MountConfig.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-26 15:07:39 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2021-06-16 13:55:19 +0200
commit1052feabede4b9054047f60aaa6fe4e04e89c434 (patch)
tree7f87fd18601f2f0648f85c5f066dcc0647c05910 /apps/files_external/lib/MountConfig.php
parent7917f4cf763a3f35f81f500b5f5b5135cd136518 (diff)
downloadnextcloud-server-1052feabede4b9054047f60aaa6fe4e04e89c434.tar.gz
nextcloud-server-1052feabede4b9054047f60aaa6fe4e04e89c434.zip
remove depricated methods from MountConfig
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib/MountConfig.php')
-rw-r--r--apps/files_external/lib/MountConfig.php113
1 files changed, 16 insertions, 97 deletions
diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php
index 0a9168bbfd7..741368a6996 100644
--- a/apps/files_external/lib/MountConfig.php
+++ b/apps/files_external/lib/MountConfig.php
@@ -66,102 +66,21 @@ class MountConfig {
// whether to skip backend test (for unit tests, as this static class is not mockable)
public static $skipTest = false;
- /** @var Application */
- public static $app;
-
- /**
- * Returns the mount points for the given user.
- * The mount point is relative to the data directory.
- *
- * @param string $uid user
- * @return array of mount point string as key, mountpoint config as value
- *
- * @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages()
- */
- public static function getAbsoluteMountPoints($uid) {
- $mountPoints = [];
-
- $userGlobalStoragesService = self::$app->getContainer()->query(UserGlobalStoragesService::class);
- $userStoragesService = self::$app->getContainer()->query(UserStoragesService::class);
- $user = self::$app->getContainer()->query(IUserManager::class)->get($uid);
-
- $userGlobalStoragesService->setUser($user);
- $userStoragesService->setUser($user);
-
- foreach ($userGlobalStoragesService->getStorages() as $storage) {
- /** @var \OCA\Files_External\Lib\StorageConfig $storage */
- $mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
- $mountEntry = self::prepareMountPointEntry($storage, false);
- foreach ($mountEntry['options'] as &$option) {
- $option = self::substitutePlaceholdersInConfig($option, $uid);
- }
- $mountPoints[$mountPoint] = $mountEntry;
- }
-
- foreach ($userStoragesService->getStorages() as $storage) {
- $mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
- $mountEntry = self::prepareMountPointEntry($storage, true);
- foreach ($mountEntry['options'] as &$option) {
- $option = self::substitutePlaceholdersInConfig($option, $uid);
- }
- $mountPoints[$mountPoint] = $mountEntry;
- }
-
- $userGlobalStoragesService->resetUser();
- $userStoragesService->resetUser();
-
- return $mountPoints;
- }
-
- /**
- * Get the system mount points
- *
- * @return array
- *
- * @deprecated 8.2.0 use GlobalStoragesService::getStorages()
- */
- public static function getSystemMountPoints() {
- $mountPoints = [];
- $service = self::$app->getContainer()->query(GlobalStoragesService::class);
-
- foreach ($service->getStorages() as $storage) {
- $mountPoints[] = self::prepareMountPointEntry($storage, false);
- }
-
- return $mountPoints;
- }
-
- /**
- * Convert a StorageConfig to the legacy mountPoints array format
- * There's a lot of extra information in here, to satisfy all of the legacy functions
- *
- * @param StorageConfig $storage
- * @param bool $isPersonal
- * @return array
- */
- private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal) {
- $mountEntry = [];
-
- $mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1); // remove leading slash
- $mountEntry['class'] = $storage->getBackend()->getIdentifier();
- $mountEntry['backend'] = $storage->getBackend()->getText();
- $mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
- $mountEntry['personal'] = $isPersonal;
- $mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
- $mountEntry['mountOptions'] = $storage->getMountOptions();
- $mountEntry['priority'] = $storage->getPriority();
- $mountEntry['applicable'] = [
- 'groups' => $storage->getApplicableGroups(),
- 'users' => $storage->getApplicableUsers(),
- ];
- // if mountpoint is applicable to all users the old API expects ['all']
- if (empty($mountEntry['applicable']['groups']) && empty($mountEntry['applicable']['users'])) {
- $mountEntry['applicable']['users'] = ['all'];
- }
-
- $mountEntry['id'] = $storage->getId();
-
- return $mountEntry;
+ /** @var UserGlobalStoragesService */
+ private $userGlobalStorageService;
+ /** @var UserStoragesService */
+ private $userStorageService;
+ /** @var GlobalStoragesService */
+ private $globalStorageService;
+
+ public function __construct(
+ UserGlobalStoragesService $userGlobalStorageService,
+ UserStoragesService $userStorageService,
+ GlobalStoragesService $globalStorageService
+ ) {
+ $this->userGlobalStorageService = $userGlobalStorageService;
+ $this->userStorageService = $userStorageService;
+ $this->globalStorageService = $globalStorageService;
}
/**
@@ -173,7 +92,7 @@ class MountConfig {
*/
public static function substitutePlaceholdersInConfig($input, string $userId = null) {
/** @var BackendService $backendService */
- $backendService = self::$app->getContainer()->query(BackendService::class);
+ $backendService = \OC::$server->get(BackendService::class);
/** @var IConfigHandler[] $handlers */
$handlers = $backendService->getConfigHandlers();
foreach ($handlers as $handler) {