command databox:unmount

This commit is contained in:
aynsix
2020-02-20 16:10:15 +03:00
parent be03773162
commit f5adf02c55
2 changed files with 62 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ 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\Databox\CreateDataboxCommand; use Alchemy\Phrasea\Command\Databox\CreateDataboxCommand;
use Alchemy\Phrasea\Command\Databox\UnMountDataboxCommand;
use Alchemy\Phrasea\Command\MailTest; use Alchemy\Phrasea\Command\MailTest;
use Alchemy\Phrasea\Command\Compile\Configuration; use Alchemy\Phrasea\Command\Compile\Configuration;
use Alchemy\Phrasea\Command\RecordAdd; 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 CreateCollection('collection:create'));
$cli->command(new CreateDataboxCommand('databox:create')); $cli->command(new CreateDataboxCommand('databox:create'));
$cli->command(new UnMountDataboxCommand('databox:unmount'));
$cli->command(new RecordAdd('records:add')); $cli->command(new RecordAdd('records:add'));
$cli->command(new RescanTechnicalDatas('records:rescan-technical-datas')); $cli->command(new RescanTechnicalDatas('records:rescan-technical-datas'));

View File

@@ -0,0 +1,60 @@
<?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\Databox;
use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class UnMountDataboxCommand extends Command
{
/**
* Constructor
*/
public function __construct($name = null)
{
parent::__construct('databox:unmount');
$this->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, '<question> Do you want really unmount this databox? (y/N)</question>', 'N'));
} while ( ! in_array($continue, ['y', 'n']));
if ($continue !== 'y') {
$output->writeln('Aborting !');
return;
}
$databox->unmount_databox();
$output->writeln('<info>Unmount databox successful</info>');
} catch (\Exception $e) {
$output->writeln('<error>Unmount databox failed : '.$e->getMessage().'</error>');
}
return 0;
}
}