setDescription('List all databox in Phraseanet') ->addOption('jsonformat', null, InputOption::VALUE_NONE, 'Output in json format') ->setHelp(''); return $this; } 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()); 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('Listing databox failed : '.$e->getMessage().''); } return 0; } private function listDatabox(\databox $databox) { return [ $databox->get_sbas_id(), $databox->get_dbname(), $databox->get_viewname() ]; } }