setName('zone:list')
->setDescription('List DNS zones')
// ->addArgument('foo', InputArgument::OPTIONAL, '')
->addOption('name', null, InputOption::VALUE_REQUIRED, '')
->setHelp("The %command.name% ");
}
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
// $this->getContainer()->get('foo.bar');
// $output->writeln(sprintf('%s bar.', $example));
// $input->getArgument('foo');
// $input->getOption('bar');
$query = $this->getZoneQuery();
$zones = $query->find();
foreach ($zones as $key => $zone) {
$this->showZone($zone, $key);
}
}
protected function getZoneQuery()
{
$query = ZoneQuery::create()->orderByName();
if ($this->getInput()->getOption('name')) {
$query->filterByName(sprintf('%%%s%%', $this->getInput()->getOption('name')));
}
return $query;
}
}