diff options
Diffstat (limited to 'apps/files_external/lib/Command/Delete.php')
-rw-r--r-- | apps/files_external/lib/Command/Delete.php | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/apps/files_external/lib/Command/Delete.php b/apps/files_external/lib/Command/Delete.php index cf09e3907b7..9f121250f7d 100644 --- a/apps/files_external/lib/Command/Delete.php +++ b/apps/files_external/lib/Command/Delete.php @@ -1,25 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Robin Appelman <robin@icewind.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\Files_External\Command; @@ -27,8 +11,10 @@ use OC\Core\Command\Base; use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\GlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; +use OCP\AppFramework\Http; use OCP\IUserManager; use OCP\IUserSession; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -37,17 +23,14 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class Delete extends Base { - protected GlobalStoragesService $globalService; - protected UserStoragesService $userService; - protected IUserSession $userSession; - protected IUserManager $userManager; - - 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, + protected QuestionHelper $questionHelper, + ) { parent::__construct(); - $this->globalService = $globalService; - $this->userService = $userService; - $this->userSession = $userSession; - $this->userManager = $userManager; } protected function configure(): void { @@ -73,7 +56,7 @@ class Delete extends Base { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); - return 404; + return Http::STATUS_NOT_FOUND; } $noConfirm = $input->getOption('yes'); @@ -84,15 +67,16 @@ class Delete extends Base { $listInput->setOption('output', $input->getOption('output')); $listCommand->listMounts(null, [$mount], $listInput, $output); + /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); if (!$questionHelper->ask($input, $output, $question)) { - return 1; + return self::FAILURE; } } $this->globalService->removeStorage($mountId); - return 0; + return self::SUCCESS; } } |