mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge branch 'master' into PHRAS-1629-collection-list-jsonformat
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Command\Databox;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ListDataboxCommand extends Command
|
||||
@@ -25,6 +26,7 @@ class ListDataboxCommand extends Command
|
||||
parent::__construct('databox:list');
|
||||
|
||||
$this->setDescription('List all databox in Phraseanet')
|
||||
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
||||
->setHelp('');
|
||||
|
||||
return $this;
|
||||
@@ -33,15 +35,23 @@ class ListDataboxCommand extends Command
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
try {
|
||||
$jsonformat = $input->getOption('jsonformat');
|
||||
$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);
|
||||
if ($jsonformat) {
|
||||
foreach ($databoxes as $databox) {
|
||||
$databoxList[] = array_combine(['id', 'name', 'alias'], $databox);
|
||||
}
|
||||
echo json_encode($databoxList);
|
||||
} else {
|
||||
$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>');
|
||||
|
@@ -42,6 +42,7 @@ class UserListCommand extends Command
|
||||
->addOption('application', null, InputOption::VALUE_NONE, 'List application of user work only if --user_id is set')
|
||||
->addOption('right', null, InputOption::VALUE_NONE, 'Show right information')
|
||||
->addOption('adress', null, InputOption::VALUE_NONE, 'Show adress information')
|
||||
->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format')
|
||||
->setHelp('');
|
||||
|
||||
return $this;
|
||||
@@ -61,6 +62,7 @@ class UserListCommand extends Command
|
||||
$created = $input->getOption('created');
|
||||
$updated = $input->getOption('updated');
|
||||
$withRight = $input->getOption('right');
|
||||
$jsonformat = $input->getOption('jsonformat');
|
||||
|
||||
$query = $this->container['phraseanet.user-query'];
|
||||
|
||||
@@ -87,24 +89,33 @@ class UserListCommand extends Command
|
||||
if ($userId and $application) {
|
||||
$showApplication = true;
|
||||
}
|
||||
$userList[] = $this->listUser($user,$withAdress,$withRight);
|
||||
$userList[] = $this->listUser($user, $withAdress, $withRight);
|
||||
|
||||
$userListRaw[] = array_combine($this->headerTable($withAdress, $withRight), $this->listUser($user, $withAdress, $withRight));
|
||||
}
|
||||
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
$table
|
||||
->setHeaders($this->headerTable($withAdress,$withRight))
|
||||
->setRows($userList)
|
||||
->render($output);
|
||||
;
|
||||
if ($jsonformat) {
|
||||
echo json_encode($userListRaw);
|
||||
} else {
|
||||
$table = $this->getHelperSet()->get('table');
|
||||
$table
|
||||
->setHeaders($this->headerTable($withAdress, $withRight))
|
||||
->setRows($userList)
|
||||
->render($output);
|
||||
;
|
||||
|
||||
|
||||
if ($showApplication) {
|
||||
$applicationTable = $this->getHelperSet()->get('table');
|
||||
$applicationTable->setHeaders(array(
|
||||
array(new TableCell('Applications', array('colspan' => 5))),
|
||||
['name','callback','client_secret','client_id','token'],
|
||||
))->setRows($this->getApplicationOfUser($users[0]))->render($output);
|
||||
}
|
||||
|
||||
if ($showApplication) {
|
||||
$applicationTable = $this->getHelperSet()->get('table');
|
||||
$applicationTable->setHeaders(array(
|
||||
array(new TableCell('Applications', array('colspan' => 5))),
|
||||
['name','callback','client_secret','client_id','token'],
|
||||
))->setRows($this->getApplicationOfUser($users[0]))->render($output);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user