/** * Interacts with the user to retrieve task configurations. * * @param OutputStyle $io */ private function interactForTaskConfigurations(OutputStyle $io) { $io->writeln(' Add tasks:'); $addTask = true; while ($addTask) { $taskQuestion = new Question('Search for a task'); $taskQuestion->setAutocompleterValues($this->getAvailableTasks()); $taskQuestion->setValidator(function ($answer) { if (class_exists($answer) === false && class_exists('Accompli\\Task\\' . $answer) === true) { $answer = 'Accompli\\Task\\' . $answer; } if (class_exists($answer) === false || in_array(TaskInterface::class, class_implements($answer)) === false) { throw new InvalidArgumentException(sprintf('The task "%s" does not exist.', $answer)); } return $answer; }); $task = $io->askQuestion($taskQuestion); $taskConfiguration = array_merge(array('class' => $task), $this->getTaskConfigurationParameters($task)); $this->configuration['events']['subscribers'][] = $taskConfiguration; $addTask = $io->confirm('Add another task?'); } }