setName('domain:remove') ->setDescription('Remove a domain') ->addOption('name', null, InputOption::VALUE_REQUIRED, '') ->addOption('id', null, InputOption::VALUE_REQUIRED, '') ->addOption('confirm', null, InputOption::VALUE_NONE, '') ->setHelp("The %command.name% "); } protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $name = $this->getInput()->getOption('name'); $id = $this->getInput()->getOption('id'); $id = $this->getInput()->getOption('id'); if (null === $name && null === $id) { $this->getOutput()->writeln('You must give a name or an id.'); return; } if ($name) { $domain = $this->getQuery()->findOneByName($name); } else { $domain = $this->getQuery()->findOneById($id); } if (null === $domain) { $this->getOutput()->writeln('No domain found.'); return; } $confirm = $this->getInput()->getOption('confirm'); if (false === $confirm) { $confirm = $this->getHelper('dialog')->askConfirmation($this->getOutput(), 'Do you confirm? [no] ', false); } if ($confirm) { $domain->delete(); $this->getOutput()->writeln('Domain removed.'); } else { $this->getOutput()->writeln('Aborted.'); } } protected function getQuery() { return DomainQuery::create(); } }