aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Service/StoragesService.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Service/StoragesService.php')
-rw-r--r--apps/files_external/lib/Service/StoragesService.php47
1 files changed, 16 insertions, 31 deletions
diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php
index 09f7ea954b4..a12a8fc245a 100644
--- a/apps/files_external/lib/Service/StoragesService.php
+++ b/apps/files_external/lib/Service/StoragesService.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -6,6 +7,7 @@
*/
namespace OCA\Files_External\Service;
+use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\InvalidAuth;
@@ -18,6 +20,8 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\StorageNotAvailableException;
+use OCP\Server;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -25,37 +29,18 @@ use Psr\Log\LoggerInterface;
*/
abstract class StoragesService {
- /** @var BackendService */
- protected $backendService;
-
- /**
- * @var DBConfigService
- */
- protected $dbConfig;
-
- /**
- * @var IUserMountCache
- */
- protected $userMountCache;
-
- protected IEventDispatcher $eventDispatcher;
-
/**
* @param BackendService $backendService
- * @param DBConfigService $dbConfigService
+ * @param DBConfigService $dbConfig
* @param IUserMountCache $userMountCache
* @param IEventDispatcher $eventDispatcher
*/
public function __construct(
- BackendService $backendService,
- DBConfigService $dbConfigService,
- IUserMountCache $userMountCache,
- IEventDispatcher $eventDispatcher
+ protected BackendService $backendService,
+ protected DBConfigService $dbConfig,
+ protected IUserMountCache $userMountCache,
+ protected IEventDispatcher $eventDispatcher,
) {
- $this->backendService = $backendService;
- $this->dbConfig = $dbConfigService;
- $this->userMountCache = $userMountCache;
- $this->eventDispatcher = $eventDispatcher;
}
protected function readDBConfig() {
@@ -93,13 +78,13 @@ abstract class StoragesService {
return $config;
} catch (\UnexpectedValueException $e) {
// don't die if a storage backend doesn't exist
- \OC::$server->get(LoggerInterface::class)->error('Could not load storage.', [
+ Server::get(LoggerInterface::class)->error('Could not load storage.', [
'app' => 'files_external',
'exception' => $e,
]);
return null;
} catch (\InvalidArgumentException $e) {
- \OC::$server->get(LoggerInterface::class)->error('Could not load storage.', [
+ Server::get(LoggerInterface::class)->error('Could not load storage.', [
'app' => 'files_external',
'exception' => $e,
]);
@@ -134,7 +119,7 @@ abstract class StoragesService {
* @return StorageConfig
* @throws NotFoundException if the storage with the given id was not found
*/
- public function getStorage($id) {
+ public function getStorage(int $id) {
$mount = $this->dbConfig->getMountById($id);
if (!is_array($mount)) {
@@ -282,7 +267,7 @@ abstract class StoragesService {
$mountOptions = null,
$applicableUsers = null,
$applicableGroups = null,
- $priority = null
+ $priority = null,
) {
$backend = $this->backendService->getBackend($backendIdentifier);
if (!$backend) {
@@ -324,7 +309,7 @@ abstract class StoragesService {
protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray): void {
$this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
foreach ($applicableArray as $applicable) {
- \OCP\Util::emitHook(
+ Util::emitHook(
Filesystem::CLASSNAME,
$signal,
[
@@ -450,7 +435,7 @@ abstract class StoragesService {
*
* @throws NotFoundException if no storage was found with the given id
*/
- public function removeStorage($id) {
+ public function removeStorage(int $id) {
$existingMount = $this->dbConfig->getMountById($id);
if (!is_array($existingMount)) {
@@ -463,7 +448,7 @@ abstract class StoragesService {
$this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount);
// delete oc_storages entries and oc_filecache
- \OC\Files\Cache\Storage::cleanByMountId($id);
+ Storage::cleanByMountId($id);
}
/**