mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-12-06 11:22:41 +01:00
added resource occ commands
This commit is contained in:
parent
0f81059343
commit
840fd70c37
8 changed files with 169 additions and 2 deletions
37
lib/Command/Resource/ListResources.php
Normal file
37
lib/Command/Resource/ListResources.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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;
|
||||
|
||||
class ListResources extends BaseCommand {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('organization-folders:list-resources')
|
||||
->addArgument('organization-folder-id', InputArgument::REQUIRED, 'Id of Organization Folder')
|
||||
->addArgument('parent-resource-id', InputArgument::OPTIONAL, 'Id of Organization Folder')
|
||||
->setDescription('List all resource in organization folder. Only shows one layer of tree at once, provide resource parent id to reveal child resources.');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
try {
|
||||
$organizationFolderId = $input->getArgument('organization-folder-id');
|
||||
$parentResourceId = $input->getArgument('parent-resource-id');
|
||||
|
||||
$resources = $this->resourceService->findAll($organizationFolderId, $parentResourceId);
|
||||
|
||||
$this->writeTableInOutputFormat($input, $output, $this->formatResources($resources));
|
||||
return 0;
|
||||
} catch (Exception $e) {
|
||||
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue