From 4dad10d23f221e55e55a52c7f78cbea7496cb53e Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Tue, 5 Nov 2024 13:46:06 +0100 Subject: [PATCH] added occ command to remove resource --- appinfo/info.xml | 1 + lib/Command/Resource/RemoveResource.php | 34 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lib/Command/Resource/RemoveResource.php diff --git a/appinfo/info.xml b/appinfo/info.xml index e0a7fe9..515e703 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -28,6 +28,7 @@ OCA\OrganizationFolders\Command\Resource\CreateResource OCA\OrganizationFolders\Command\Resource\ListResources OCA\OrganizationFolders\Command\Resource\UpdateResource + OCA\OrganizationFolders\Command\Resource\RemoveResource OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember OCA\OrganizationFolders\Command\ResourceMember\ListResourceMembers OCA\OrganizationFolders\Command\ResourceMember\RemoveResourceMember diff --git a/lib/Command/Resource/RemoveResource.php b/lib/Command/Resource/RemoveResource.php new file mode 100644 index 0000000..0d36598 --- /dev/null +++ b/lib/Command/Resource/RemoveResource.php @@ -0,0 +1,34 @@ +setName('organization-folders:remove-resource') + ->setDescription('Remove a resource') + ->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("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); + return 1; + } + } +}