mirror of
https://github.com/nextcloud/server.git
synced 2026-11-08 01:15:43 +01:00
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Sharing\Command;
|
|
|
|
use Exception;
|
|
use NCU\Sharing\Exception\AShareException;
|
|
use OC\Core\Command\Base;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
final class DeleteShare extends SharingBase {
|
|
#[\Override]
|
|
public function configure(): void {
|
|
$this
|
|
->setName('sharing:delete-share')
|
|
->setDescription('Delete a share.')
|
|
->addArgument('id', InputArgument::REQUIRED, 'Share ID');
|
|
parent::configure();
|
|
}
|
|
|
|
#[\Override]
|
|
public function execute(InputInterface $input, OutputInterface $output): int {
|
|
/** @var string $id */
|
|
$id = $input->getArgument('id');
|
|
$this->applyActor($input);
|
|
|
|
try {
|
|
try {
|
|
$this->dbConnection->beginTransaction();
|
|
|
|
$share = $this->manager->getShare($this->accessContext, $id);
|
|
$this->manager->deleteShare($this->accessContext, $share);
|
|
$this->dbConnection->commit();
|
|
return Base::SUCCESS;
|
|
} catch (Exception $exception) {
|
|
$this->dbConnection->rollBack();
|
|
throw $exception;
|
|
}
|
|
} catch (AShareException $aShareException) {
|
|
if ($output instanceof ConsoleOutputInterface) {
|
|
$output = $output->getErrorOutput();
|
|
}
|
|
|
|
$output->writeln($aShareException->getMessage());
|
|
return Base::FAILURE;
|
|
}
|
|
}
|
|
}
|