0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-24 05:30:27 +01:00
organization_folders/lib/Command/Resource/DeleteResource.php

35 lines
941 B
PHP
Raw Permalink Normal View History

2024-11-05 13:46:06 +01:00
<?php
namespace OCA\OrganizationFolders\Command\Resource;
use OCP\DB\Exception;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use OCA\OrganizationFolders\Command\BaseCommand;
2024-11-05 14:05:04 +01:00
class DeleteResource extends BaseCommand {
2024-11-05 13:46:06 +01:00
protected function configure(): void {
$this
2024-11-05 14:05:04 +01:00
->setName('organization-folders:resources:delete')
->setDescription('Delete a resource')
2024-11-05 13:46:06 +01:00
->addArgument('id', InputArgument::REQUIRED, 'Id of the resource');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$id = (int)$input->getArgument('id');
try {
$this->resourceService->deleteById($id);
$output->writeln("done");
return 0;
} catch (Exception $e) {
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
return 1;
}
}
}