mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge pull request #3355 from alchemy-fr/PHRAS-1627-databox-list
PHRAS-1627 #merge of bin/console databox:list
This commit is contained in:
@@ -24,6 +24,7 @@ use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand;
|
||||
use Alchemy\Phrasea\Core\Version;
|
||||
use Alchemy\Phrasea\Command\CreateCollection;
|
||||
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;
|
||||
@@ -108,6 +109,8 @@ $cli->command(new \module_console_fieldsRename('fields:rename'));
|
||||
$cli->command(new \module_console_fieldsMerge('fields:merge'));
|
||||
|
||||
$cli->command(new CreateCollection('collection:create'));
|
||||
|
||||
$cli->command(new ListDataboxCommand('databox:list'));
|
||||
$cli->command(new CreateDataboxCommand('databox:create'));
|
||||
|
||||
$cli->command(new RecordAdd('records:add'));
|
||||
|
62
lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php
Normal file
62
lib/Alchemy/Phrasea/Command/Databox/ListDataboxCommand.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Databox;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ListDataboxCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct('databox:list');
|
||||
|
||||
$this->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('<error>Listing databox failed : '.$e->getMessage().'</error>');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function listDatabox(\databox $databox)
|
||||
{
|
||||
return [
|
||||
$databox->get_sbas_id(),
|
||||
$databox->get_dbname(),
|
||||
$databox->get_viewname()
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user