mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
command collection:unpublish
This commit is contained in:
@@ -23,6 +23,7 @@ use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand;
|
|||||||
use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand;
|
use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand;
|
||||||
use Alchemy\Phrasea\Core\Version;
|
use Alchemy\Phrasea\Core\Version;
|
||||||
use Alchemy\Phrasea\Command\CreateCollection;
|
use Alchemy\Phrasea\Command\CreateCollection;
|
||||||
|
use Alchemy\Phrasea\Command\Collection\UnPublishCollectionCommand;
|
||||||
use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand;
|
use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand;
|
||||||
use Alchemy\Phrasea\Command\MailTest;
|
use Alchemy\Phrasea\Command\MailTest;
|
||||||
use Alchemy\Phrasea\Command\Compile\Configuration;
|
use Alchemy\Phrasea\Command\Compile\Configuration;
|
||||||
@@ -108,6 +109,7 @@ $cli->command(new \module_console_fieldsRename('fields:rename'));
|
|||||||
$cli->command(new \module_console_fieldsMerge('fields:merge'));
|
$cli->command(new \module_console_fieldsMerge('fields:merge'));
|
||||||
|
|
||||||
$cli->command(new CreateCollection('collection:create'));
|
$cli->command(new CreateCollection('collection:create'));
|
||||||
|
$cli->command(new UnPublishCollectionCommand('collection:unpublish'));
|
||||||
$cli->command(new CreateDataboxCommand('databox:create'));
|
$cli->command(new CreateDataboxCommand('databox:create'));
|
||||||
|
|
||||||
$cli->command(new RecordAdd('records:add'));
|
$cli->command(new RecordAdd('records:add'));
|
||||||
|
@@ -0,0 +1,61 @@
|
|||||||
|
<?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\Collection;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
|
class UnPublishCollectionCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct('collection:unpublish');
|
||||||
|
|
||||||
|
$this->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, '<question> Do you want really unpublish this collection? (y/N)</question>', 'N'));
|
||||||
|
} while ( ! in_array($continue, ['y', 'n']));
|
||||||
|
|
||||||
|
if ($continue !== 'y') {
|
||||||
|
$output->writeln('Aborting !');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$collection->disable($this->container->getApplicationBox());
|
||||||
|
$output->writeln('<info>Unpublish collection successful</info>');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$output->writeln('<error>Unpublish collection failed : '.$e->getMessage().'</error>');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user