public function addActions(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper) { $output->writeln(array('', 'Instead of starting with a blank controller, you can add some actions now. An action', 'is a PHP function or method that executes, for example, when a given route is matched.', 'Actions should be suffixed by <comment>Action</comment>.', '')); $actions = $this->parseActions($input->getOption('actions')); while (true) { // name $output->writeln(''); $question = new Question($questionHelper->getQuestion('New action name (press <return> to stop adding actions)', null), null); $question->setValidator(function ($name) use($actions) { if (null == $name) { return $name; } if (isset($actions[$name])) { throw new \InvalidArgumentException(sprintf('Action "%s" is already defined', $name)); } if ('Action' != substr($name, -6)) { throw new \InvalidArgumentException(sprintf('Name "%s" is not suffixed by Action', $name)); } return $name; }); $actionName = $questionHelper->ask($input, $output, $question); if (!$actionName) { break; } // route /*$question = new Question($questionHelper->getQuestion('Action route', '/'.substr($actionName, 0, -6)), '/'.substr($actionName, 0, -6)); $route = $questionHelper->ask($input, $output, $question); $placeholders = $this->getPlaceholdersFromRoute($route);*/ // adding action $actions[$actionName] = array('name' => $actionName); } return $actions; }