setDescription('Delete a documentation field from a Databox');
$this->addArgument('meta_struct_id', InputArgument::REQUIRED, 'Metadata structure id destination');
$this->addArgument('sbas_id', InputArgument::REQUIRED, 'Databox sbas_id');
return $this;
}
public function requireSetup()
{
return true;
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
try {
$databox = \databox::get_instance((int) $input->getArgument('sbas_id'));
} catch (\Exception $e) {
$output->writeln("Invalid databox id ");
return 1;
}
try {
$field = $databox->get_meta_structure()->get_element((int) $input->getArgument('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;
}
}