1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2024-11-24 13:42:47 +01:00
Nextcloud-News/lib/Command/Config/FolderDelete.php
Sean Molenaar b4fa772bc5 Remove V1 item API
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
2021-02-13 13:22:57 +01:00

61 lines
1.5 KiB
PHP

<?php
namespace OCA\News\Command\Config;
use OCA\News\Service\Exceptions\ServiceValidationException;
use OCA\News\Service\FolderServiceV2;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class FolderDelete extends Command
{
/**
* @var FolderServiceV2 service for the folders.
*/
protected $folderService;
public function __construct(FolderServiceV2 $folderService)
{
parent::__construct(null);
$this->folderService = $folderService;
}
/**
* Configure command
*
* @return void
*/
protected function configure()
{
$this->setName('news:folder:delete')
->setDescription('Remove a folder')
->addArgument('user-id', InputArgument::REQUIRED, 'User to remove the folder from')
->addArgument('folder-id', InputArgument::REQUIRED, 'Folder ID', null);
}
/**
* Execute command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$user = $input->getArgument('user-id');
$id = $input->getArgument('folder-id');
if ($id === null) {
throw new ServiceValidationException('Can not remove root folder!');
}
$this->folderService->delete($user, intval($id));
return 0;
}
}