diff --git a/bin/console b/bin/console index 552cb672d0..e42afb9a99 100755 --- a/bin/console +++ b/bin/console @@ -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\UnMountDataboxCommand; use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\Compile\Configuration; use Alchemy\Phrasea\Command\RecordAdd; @@ -109,6 +110,7 @@ $cli->command(new \module_console_fieldsMerge('fields:merge')); $cli->command(new CreateCollection('collection:create')); $cli->command(new CreateDataboxCommand('databox:create')); +$cli->command(new UnMountDataboxCommand('databox:unmount')); $cli->command(new RecordAdd('records:add')); $cli->command(new RescanTechnicalDatas('records:rescan-technical-datas')); diff --git a/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php b/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php new file mode 100644 index 0000000000..42199a519f --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Databox/UnMountDataboxCommand.php @@ -0,0 +1,60 @@ +setDescription('Unmount databox') + ->addArgument('databox_id', InputArgument::REQUIRED, 'The id of the databox to unmount', null) + ; + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + $databox = $this->container->findDataboxById($input->getArgument('databox_id')); + $dialog = $this->getHelperSet()->get('dialog'); + + do { + $continue = mb_strtolower($dialog->ask($output, ' Do you want really unmount this databox? (y/N)', 'N')); + } while ( ! in_array($continue, ['y', 'n'])); + + if ($continue !== 'y') { + $output->writeln('Aborting !'); + + return; + } + + $databox->unmount_databox(); + $output->writeln('Unmount databox successful'); + } catch (\Exception $e) { + $output->writeln('Unmount databox failed : '.$e->getMessage().''); + } + + return 0; + } + +}