setName('zone:record:remove')
->setDescription('Remove a zone record')
->addArgument('id', InputArgument::REQUIRED, 'Record ID (the record can not be associated with an active zone version)')
->addOption('confirm', null, InputOption::VALUE_NONE, 'Confirmation');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
$id = (int) $this->getInput()->getArgument('id');
$zoneRecord = ZoneRecordQuery::create()->findOneById($id);
if (null === $zoneRecord) {
$this->getOutput()->writeln('Zone record not found.');
return;
}
if ($zoneRecord->getZoneVersion()->getIsActive()) {
$this->getOutput()->writeln('You can not remove a record of an active zone version.');
return;
}
$confirm = $this->getInput()->getOption('confirm');
if (false === $confirm) {
$confirm = $this->getHelper('dialog')->askConfirmation($this->getOutput(), 'Do you confirm? [no] ', false);
}
if ($confirm) {
$zoneRecord->delete();
$this->getOutput()->writeln('Zone record removed.');
} else {
$this->getOutput()->writeln('Aborted.');
}
}
}