@@ -215,13 +215,33 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
215215 {
216216 $ helper = $ this ->getHelper ('question ' );
217217 $ configOptionsToValidate = [];
218+
218219 foreach ($ this ->configModel ->getAvailableOptions () as $ option ) {
220+ $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
221+ $ input ,
222+ $ output ,
223+ $ helper ,
224+ $ option ,
225+ true
226+ );
227+ }
219228
220- $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion ($ input , $ output , $ helper , $ option );
229+ foreach ($ this ->userConfig ->getOptionsList () as $ option ) {
230+ $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
231+ $ input ,
232+ $ output ,
233+ $ helper ,
234+ $ option
235+ );
236+ }
221237
222- /*$question = new Question($option->getDescription() . '? ', $option->getDefault());
223- $configOptionsToValidate[$option->getName()] = $helper->ask($input, $output, $question);
224- */
238+ foreach ($ this ->adminUser ->getOptionsList () as $ option ) {
239+ $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
240+ $ input ,
241+ $ output ,
242+ $ helper ,
243+ $ option
244+ );
225245 }
226246 return $ configOptionsToValidate ;
227247 }
@@ -234,11 +254,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
234254 * @param InputInterface $input
235255 * @param OutputInterface $output
236256 * @param QuestionHelper $helper
237- * @param Magento\Framework\Setup\Option\TextConfigOption|Magento\Framework\Setup\Option\FlagConfigOption\Magento\Framework\Setup\Option\SelectConfigOption $option
257+ * @param TextConfigOption|FlagConfigOption\SelectConfigOption $option
258+ * @param Boolean $validateInline
238259 * @return string[] Array of inputs
239260 */
240- private function askQuestion (InputInterface $ input , OutputInterface $ output , QuestionHelper $ helper , $ option )
241- {
261+ private function askQuestion (
262+ InputInterface $ input ,
263+ OutputInterface $ output ,
264+ QuestionHelper $ helper ,
265+ $ option ,
266+ $ validateInline = false
267+ ) {
242268 if (get_class ($ option ) === 'Magento\Framework\Setup\Option\SelectConfigOption ' ) {
243269 if ($ option ->isValueRequired ()) {
244270 $ question = new ChoiceQuestion (
@@ -253,10 +279,6 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que
253279 $ option ->getDefault ()
254280 );
255281 }
256- $ question ->setValidator (function ($ answer ) use ($ option ) {
257- $ option ->validate ($ option ->getSelectOptions ()[$ answer ]);
258- return $ answer ;
259- });
260282 } else {
261283 if ($ option ->isValueRequired ()) {
262284 $ question = new Question (
@@ -269,13 +291,25 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que
269291 $ option ->getDefault ()
270292 );
271293 }
272- $ question ->setValidator (function ($ answer ) use ($ option ) {
273- $ option ->validate ($ answer );
274- return $ answer ;
275- });
294+
276295 }
277296
297+ $ question ->setValidator (function ($ answer ) use ($ option , $ validateInline ) {
298+ $ answer = trim ($ answer );
299+
300+ if (get_class ($ option ) === 'Magento\Framework\Setup\Option\SelectConfigOption ' ) {
301+ $ answer = $ option ->getSelectOptions ()[$ answer ];
302+ }
303+
304+ if ($ validateInline ) {
305+ $ option ->validate ($ answer );
306+ }
307+
308+ return $ answer ;
309+ });
310+
278311 $ value = $ helper ->ask ($ input , $ output , $ question );
312+
279313 return $ value ;
280314 }
281- }
315+ }
0 commit comments