0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-24 21:50:26 +01:00
organization_folders/lib/Command/Resource/ListResources.php

38 lines
1.4 KiB
PHP
Raw Normal View History

2024-10-30 04:45:56 +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;
class ListResources extends BaseCommand {
protected function configure(): void {
$this
2024-11-05 14:05:04 +01:00
->setName('organization-folders:resources:list')
2024-10-30 04:45:56 +01:00
->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);
2024-10-31 17:29:15 +01:00
$this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($resources));
2024-10-30 04:45:56 +01:00
return 0;
} catch (Exception $e) {
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
return 1;
}
}
}