aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Command/ListCommand.php
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-07-04 12:34:36 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2023-09-28 09:02:10 +0330
commit32838d8f0a99393dafb1ba0844c55fc257cc7a84 (patch)
tree4c95516699a5b8b7612d7b49c51661abce0c4517 /apps/files_external/lib/Command/ListCommand.php
parentc2e4a7be920af69ece4a68e9a410155a718355db (diff)
downloadnextcloud-server-32838d8f0a99393dafb1ba0844c55fc257cc7a84.tar.gz
nextcloud-server-32838d8f0a99393dafb1ba0844c55fc257cc7a84.zip
Refactors files_external app commands.
To improve code readability. Signed-off-by: Faraz Samapoor <fsa@adlas.at> Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'apps/files_external/lib/Command/ListCommand.php')
-rw-r--r--apps/files_external/lib/Command/ListCommand.php37
1 files changed, 17 insertions, 20 deletions
diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php
index b2a4baf366b..929e9d4f515 100644
--- a/apps/files_external/lib/Command/ListCommand.php
+++ b/apps/files_external/lib/Command/ListCommand.php
@@ -29,6 +29,7 @@ use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
@@ -39,19 +40,15 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ListCommand extends Base {
- protected GlobalStoragesService $globalService;
- protected UserStoragesService $userService;
- protected IUserSession $userSession;
- protected IUserManager $userManager;
-
public const ALL = -1;
- public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
+ public function __construct(
+ protected GlobalStoragesService $globalService,
+ protected UserStoragesService $userService,
+ protected IUserSession $userSession,
+ protected IUserManager $userManager,
+ ) {
parent::__construct();
- $this->globalService = $globalService;
- $this->userService = $userService;
- $this->userSession = $userSession;
- $this->userManager = $userManager;
}
protected function configure(): void {
@@ -93,7 +90,7 @@ class ListCommand extends Base {
}
$this->listMounts($userId, $mounts, $input, $output);
- return 0;
+ return self::SUCCESS;
}
/**
@@ -245,16 +242,16 @@ class ListCommand extends Base {
}
}
- protected function getStorageService($userId) {
- if (!empty($userId)) {
- $user = $this->userManager->get($userId);
- if (is_null($user)) {
- throw new NoUserException("user $userId not found");
- }
- $this->userSession->setUser($user);
- return $this->userService;
- } else {
+ protected function getStorageService($userId): StoragesService {
+ if (empty($userId)) {
return $this->globalService;
}
+
+ $user = $this->userManager->get($userId);
+ if (is_null($user)) {
+ throw new NoUserException("user $userId not found");
+ }
+ $this->userSession->setUser($user);
+ return $this->userService;
}
}