setName('zone:add') ->setDescription('Add a zone') ->addOption('name', null, InputOption::VALUE_REQUIRED, '') ->addOption('description', null, InputOption::VALUE_REQUIRED, '') ->setHelp("The %command.name% "); } protected function execute(InputInterface $input, OutputInterface $output) { parent::execute($input, $output); $name = $this->getInput()->getOption('name'); $description = $this->getInput()->getOption('description'); while (null === $name || trim($name) === '') { $name = $this->getHelper('dialog')->ask($this->getOutput(), 'Name: ', null); } if (null === $description || trim($description) === '') { $description = $this->getHelper('dialog')->ask($this->getOutput(), 'Description: ', null); } $zone = (new Zone()) ->setName($name) ->setDescription($description) ->save(); $this->getOutput()->writeln('Zone added.'); } }