mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
Merge branch 'master' into PHRAS-1659-user-create
This commit is contained in:
@@ -24,20 +24,30 @@ class ListCollectionCommand extends Command
|
|||||||
parent::__construct('collection:list');
|
parent::__construct('collection:list');
|
||||||
$this->setDescription('List all collection in Phraseanet')
|
$this->setDescription('List all collection in Phraseanet')
|
||||||
->addOption('databox_id', 'd', InputOption::VALUE_REQUIRED, 'The id of the databox to list collection')
|
->addOption('databox_id', 'd', InputOption::VALUE_REQUIRED, 'The id of the databox to list collection')
|
||||||
|
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
||||||
->setHelp('');
|
->setHelp('');
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$databox = $this->container->findDataboxById($input->getOption('databox_id'));
|
$jsonformat = $input->getOption('jsonformat');
|
||||||
$collections = $this->listDataboxCollections($databox);
|
$databox = $this->container->findDataboxById($input->getOption('databox_id'));
|
||||||
|
$collections = $this->listDataboxCollections($databox);
|
||||||
|
|
||||||
|
if ($jsonformat) {
|
||||||
|
foreach ($collections as $collection) {
|
||||||
|
$collectionList[] = array_combine(['id local for API', 'id distant', 'name','label','status','total records'], $collection);
|
||||||
|
}
|
||||||
|
echo json_encode($collectionList);
|
||||||
|
} else {
|
||||||
|
$table = $this->getHelperSet()->get('table');
|
||||||
|
$table
|
||||||
|
->setHeaders(['id local for API', 'id distant', 'name','label','status','total records'])
|
||||||
|
->setRows($collections)
|
||||||
|
->render($output);
|
||||||
|
}
|
||||||
|
|
||||||
$table = $this->getHelperSet()->get('table');
|
|
||||||
$table
|
|
||||||
->setHeaders(['id local for API', 'id distant', 'name','label','status','total records'])
|
|
||||||
->setRows($collections)
|
|
||||||
->render($output);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln("<error>{$e->getMessage()}</error>");
|
$output->writeln("<error>{$e->getMessage()}</error>");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Command\Databox;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Command\Command;
|
use Alchemy\Phrasea\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class ListDataboxCommand extends Command
|
class ListDataboxCommand extends Command
|
||||||
@@ -25,6 +26,7 @@ class ListDataboxCommand extends Command
|
|||||||
parent::__construct('databox:list');
|
parent::__construct('databox:list');
|
||||||
|
|
||||||
$this->setDescription('List all databox in Phraseanet')
|
$this->setDescription('List all databox in Phraseanet')
|
||||||
|
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
||||||
->setHelp('');
|
->setHelp('');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -33,15 +35,23 @@ class ListDataboxCommand extends Command
|
|||||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$jsonformat = $input->getOption('jsonformat');
|
||||||
$databoxes = array_map(function (\databox $databox) {
|
$databoxes = array_map(function (\databox $databox) {
|
||||||
return $this->listDatabox($databox);
|
return $this->listDatabox($databox);
|
||||||
}, $this->container->getApplicationBox()->get_databoxes());
|
}, $this->container->getApplicationBox()->get_databoxes());
|
||||||
|
|
||||||
$table = $this->getHelperSet()->get('table');
|
if ($jsonformat) {
|
||||||
$table
|
foreach ($databoxes as $databox) {
|
||||||
->setHeaders(['id', 'name', 'alias'])
|
$databoxList[] = array_combine(['id', 'name', 'alias'], $databox);
|
||||||
->setRows($databoxes)
|
}
|
||||||
->render($output);
|
echo json_encode($databoxList);
|
||||||
|
} else {
|
||||||
|
$table = $this->getHelperSet()->get('table');
|
||||||
|
$table
|
||||||
|
->setHeaders(['id', 'name', 'alias'])
|
||||||
|
->setRows($databoxes)
|
||||||
|
->render($output);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln('<error>Listing databox failed : '.$e->getMessage().'</error>');
|
$output->writeln('<error>Listing databox failed : '.$e->getMessage().'</error>');
|
||||||
|
|||||||
Reference in New Issue
Block a user