setName('zone:version:remove') ->setDescription('Remove an unactivated zone version') ->addArgument('zone_id', InputArgument::REQUIRED, 'Zone ID') ->addArgument('version', InputArgument::REQUIRED, 'Zone version') ->addOption('confirm', null, InputOption::VALUE_NONE, ''); } protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $zoneId = (int) $this->getInput()->getArgument('zone_id'); $version = (int) $this->getInput()->getArgument('version'); $zoneVersion = ZoneVersionQuery::create() ->filterByZoneId($zoneId) ->filterByVersion($version) ->findOne(); if (null === $zoneVersion) { $this->getOutput()->writeln('Zone version not found.'); return; } if ($zoneVersion->getIsActive()) { $this->getOutput()->writeln('You can not remove an activated 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) { $zoneVersion->delete(); $this->getOutput()->writeln('Zone version removed.'); } else { $this->getOutput()->writeln('Aborted.'); } } }