diff --git a/bin/console b/bin/console index acdceffd1c..6cff909481 100755 --- a/bin/console +++ b/bin/console @@ -23,6 +23,7 @@ use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand; use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\CreateCollection; +use Alchemy\Phrasea\Command\Collection\UnPublishCollectionCommand; use Alchemy\Phrasea\Command\Collection\PublishCollectionCommand; use Alchemy\Phrasea\Command\Collection\ListCollectionCommand; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand; @@ -116,15 +117,12 @@ $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 UnPublishCollectionCommand('collection:unpublish')); $cli->command(new PublishCollectionCommand('collection:publish')); - - $cli->command(new ListCollectionCommand('collection:list')); $cli->command(new ListDataboxCommand('databox:list')); $cli->command(new CreateDataboxCommand('databox:create')); - $cli->command(new UnMountDataboxCommand('databox:unmount')); $cli->command(new MountDataboxCommand('databox:mount')); diff --git a/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php new file mode 100644 index 0000000000..ef0fc9dae5 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Collection/UnPublishCollectionCommand.php @@ -0,0 +1,61 @@ +setDescription('Unpublish collection in Phraseanet') + ->addOption('collection_id', null, InputOption::VALUE_REQUIRED, 'The base_id of the collection to unpublish, the base_id is the same id used in API.') + ->setHelp(''); + + return $this; + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + try { + + $collection = \collection::getByBaseId($this->container,(int)$input->getOption('collection_id')); + $dialog = $this->getHelperSet()->get('dialog'); + + do { + $continue = mb_strtolower($dialog->ask($output, sprintf(" Do you want really unpublish the collection %s? (y/N)", $collection->get_name()), 'N')); + } while ( ! in_array($continue, ['y', 'n'])); + + if ($continue !== 'y') { + $output->writeln('Aborting !'); + + return; + } + + $collection->disable($this->container->getApplicationBox()); + $output->writeln('Unpublish collection successful'); + } catch (\Exception $e) { + $output->writeln('Unpublish collection failed : '.$e->getMessage().''); + } + + return 0; + } + +}