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:
parent
4e120250e1
commit
21f3a39b06
5 changed files with 80 additions and 2 deletions
|
@ -19,8 +19,10 @@
|
||||||
<nextcloud min-version="29" max-version="30"/>
|
<nextcloud min-version="29" max-version="30"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<commands>
|
<commands>
|
||||||
|
<command>OCA\OrganizationFolders\Command\OrganizationFolder\GetOrganizationFolder</command>
|
||||||
<command>OCA\OrganizationFolders\Command\OrganizationFolder\ListOrganizationFolders</command>
|
<command>OCA\OrganizationFolders\Command\OrganizationFolder\ListOrganizationFolders</command>
|
||||||
<command>OCA\OrganizationFolders\Command\OrganizationFolder\CreateOrganizationFolder</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\CreateResource</command>
|
||||||
<command>OCA\OrganizationFolders\Command\Resource\ListResources</command>
|
<command>OCA\OrganizationFolders\Command\Resource\ListResources</command>
|
||||||
<command>OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember</command>
|
<command>OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember</command>
|
||||||
|
|
34
lib/Command/OrganizationFolder/GetOrganizationFolder.php
Normal file
34
lib/Command/OrganizationFolder/GetOrganizationFolder.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,9 +19,9 @@ class ListOrganizationFolders extends BaseCommand {
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||||
try {
|
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;
|
return 0;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
|
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
|
||||||
|
|
34
lib/Command/OrganizationFolder/RemoveOrganizationFolder.php
Normal file
34
lib/Command/OrganizationFolder/RemoveOrganizationFolder.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,14 @@ class OrganizationFolder implements JsonSerializable, TableSerializable {
|
||||||
return $this->quota;
|
return $this->quota;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrganizationProvider(): string {
|
||||||
|
return $this->organizationProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrganizationId(): int {
|
||||||
|
return $this->organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|
Loading…
Reference in a new issue