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
{
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
}
catch (\Exception $e)
{
$output->writeln("Invalid databox id ");
return 1;
}
try
{
$field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
}
catch (\Exception $e)
{
$output->writeln("Invalid meta struct id ");
return 1;
}
$dialog = $this->getHelperSet()->get('dialog');
$continue = mb_strtolower(
$dialog->ask(
$output
, "About to delete " . $field->get_name() . " (y/N)"
, 'n'
)
);
if($continue != 'y')
{
$output->writeln("Request canceled by user");
return 1;
}
$output->writeln("Deleting ... ");
$field->delete();
$output->writeln("Done with success !");
return 0;
}
}