mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Fix CS
This commit is contained in:
@@ -25,74 +25,66 @@ use Symfony\Component\Console\Command\Command;
|
||||
class module_console_fieldsDelete extends Command
|
||||
{
|
||||
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
$this->setDescription('Delete a documentation field from a Databox');
|
||||
|
||||
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
|
||||
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
|
||||
if (!$input->getOption('sbas_id'))
|
||||
throw new \Exception('Missing argument sbas_id');
|
||||
|
||||
if (!$input->getOption('meta_struct_id'))
|
||||
throw new \Exception('Missing argument meta_struct_id');
|
||||
|
||||
try
|
||||
public function __construct($name = null)
|
||||
{
|
||||
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$output->writeln("<error>Invalid databox id </error>");
|
||||
parent::__construct($name);
|
||||
|
||||
return 1;
|
||||
$this->setDescription('Delete a documentation field from a Databox');
|
||||
|
||||
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||
|
||||
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
try
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
|
||||
|
||||
if ( ! $input->getOption('sbas_id'))
|
||||
throw new \Exception('Missing argument sbas_id');
|
||||
|
||||
if ( ! $input->getOption('meta_struct_id'))
|
||||
throw new \Exception('Missing argument meta_struct_id');
|
||||
|
||||
try {
|
||||
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid databox id </error>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln("<error>Invalid meta struct id </error>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
$dialog = $this->getHelperSet()->get('dialog');
|
||||
$continue = mb_strtolower(
|
||||
$dialog->ask(
|
||||
$output
|
||||
, "<question>About to delete " . $field->get_name() . " (y/N)</question>"
|
||||
, 'n'
|
||||
)
|
||||
);
|
||||
|
||||
if ($continue != 'y') {
|
||||
$output->writeln("Request canceled by user");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$output->writeln("Deleting ... ");
|
||||
|
||||
$field->delete();
|
||||
|
||||
$output->writeln("Done with success !");
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$output->writeln("<error>Invalid meta struct id </error>");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
$dialog = $this->getHelperSet()->get('dialog');
|
||||
$continue = mb_strtolower(
|
||||
$dialog->ask(
|
||||
$output
|
||||
, "<question>About to delete " . $field->get_name() . " (y/N)</question>"
|
||||
, 'n'
|
||||
)
|
||||
);
|
||||
|
||||
if($continue != 'y')
|
||||
{
|
||||
$output->writeln("Request canceled by user");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$output->writeln("Deleting ... ");
|
||||
|
||||
$field->delete();
|
||||
|
||||
$output->writeln("Done with success !");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user