0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-21 20:28:11 +01:00

added occ commands to get organization folder by id and to remove organization folder

This commit is contained in:
Jonathan Treffler 2024-11-02 20:17:40 +01:00
parent 4e120250e1
commit 21f3a39b06
5 changed files with 80 additions and 2 deletions

View file

@ -19,8 +19,10 @@
<nextcloud min-version="29" max-version="30"/>
</dependencies>
<commands>
<command>OCA\OrganizationFolders\Command\OrganizationFolder\GetOrganizationFolder</command>
<command>OCA\OrganizationFolders\Command\OrganizationFolder\ListOrganizationFolders</command>
<command>OCA\OrganizationFolders\Command\OrganizationFolder\CreateOrganizationFolder</command>
<command>OCA\OrganizationFolders\Command\OrganizationFolder\RemoveOrganizationFolder</command>
<command>OCA\OrganizationFolders\Command\Resource\CreateResource</command>
<command>OCA\OrganizationFolders\Command\Resource\ListResources</command>
<command>OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember</command>

View file

@ -0,0 +1,34 @@
<?php
namespace OCA\OrganizationFolders\Command\OrganizationFolder;
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;
class GetOrganizationFolder extends BaseCommand {
protected function configure(): void {
$this
->setName('organization-folders:get')
->setDescription('Get organization folder by id')
->addArgument('id', null, InputArgument::REQUIRED, 'Id of the organization folder to get');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$id = (int)$input->getArgument('id');
try {
$organizationFolder = $this->organizationFolderService->find($id);
$this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($organizationFolder)]);
return 0;
} catch (Exception $e) {
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
return 1;
}
}
}

View file

@ -19,9 +19,9 @@ class ListOrganizationFolders extends BaseCommand {
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$organizationFolderGroupfolders = $this->organizationFolderService->findAll();
$organizationFolders = $this->organizationFolderService->findAll();
$this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($organizationFolderGroupfolders));
$this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($organizationFolders));
return 0;
} catch (Exception $e) {
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");

View file

@ -0,0 +1,34 @@
<?php
namespace OCA\OrganizationFolders\Command\OrganizationFolder;
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;
class RemoveOrganizationFolder extends BaseCommand {
protected function configure(): void {
$this
->setName('organization-folders:remove')
->setDescription('Remove a new organization folder')
->addArgument('id', null, InputArgument::REQUIRED, 'Id of the organization folder to remove');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$id = (int)$input->getArgument('id');
try {
$this->organizationFolderService->remove($id);
$output->writeln("done");
return 0;
} catch (Exception $e) {
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
return 1;
}
}
}

View file

@ -27,6 +27,14 @@ class OrganizationFolder implements JsonSerializable, TableSerializable {
return $this->quota;
}
public function getOrganizationProvider(): string {
return $this->organizationProvider;
}
public function getOrganizationId(): int {
return $this->organizationId;
}
public function jsonSerialize(): array {
return [
'id' => $this->id,