diff --git a/bin/console b/bin/console index 66c0450c79..662677f41f 100755 --- a/bin/console +++ b/bin/console @@ -25,6 +25,7 @@ use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\CreateCollection; use Alchemy\Phrasea\Command\Collection\ListCollectionCommand; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand; +use Alchemy\Phrasea\Command\Databox\ListDataboxCommand; use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\Compile\Configuration; use Alchemy\Phrasea\Command\RecordAdd; @@ -111,6 +112,7 @@ $cli->command(new \module_console_fieldsMerge('fields:merge')); $cli->command(new CreateCollection('collection:create')); $cli->command(new ListCollectionCommand('collection:list')); +$cli->command(new ListDataboxCommand('databox:list')); $cli->command(new CreateDataboxCommand('databox:create')); $cli->command(new RecordAdd('records:add')); diff --git a/lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php b/lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php new file mode 100644 index 0000000000..49775437d5 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php @@ -0,0 +1,62 @@ +setDescription('List all databox in Phraseanet') + ->setHelp(''); + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + $databoxes = array_map(function (\databox $databox) { + return $this->listDatabox($databox); + }, $this->container->getApplicationBox()->get_databoxes()); + + $table = $this->getHelperSet()->get('table'); + $table + ->setHeaders(['id', 'name', 'alias']) + ->setRows($databoxes) + ->render($output); + + } catch (\Exception $e) { + $output->writeln('Listing databox failed : '.$e->getMessage().''); + } + + return 0; + } + + private function listDatabox(\databox $databox) + { + return [ + $databox->get_sbas_id(), + $databox->get_dbname(), + $databox->get_viewname() + ]; + } + +}