@@ -215,13 +215,33 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
215
215
{
216
216
$ helper = $ this ->getHelper ('question ' );
217
217
$ configOptionsToValidate = [];
218
+
218
219
foreach ($ this ->configModel ->getAvailableOptions () as $ option ) {
220
+ $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
221
+ $ input ,
222
+ $ output ,
223
+ $ helper ,
224
+ $ option ,
225
+ true
226
+ );
227
+ }
219
228
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
+ }
221
237
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
+ );
225
245
}
226
246
return $ configOptionsToValidate ;
227
247
}
@@ -234,11 +254,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
234
254
* @param InputInterface $input
235
255
* @param OutputInterface $output
236
256
* @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
238
259
* @return string[] Array of inputs
239
260
*/
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
+ ) {
242
268
if (get_class ($ option ) === 'Magento\Framework\Setup\Option\SelectConfigOption ' ) {
243
269
if ($ option ->isValueRequired ()) {
244
270
$ question = new ChoiceQuestion (
@@ -253,10 +279,6 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que
253
279
$ option ->getDefault ()
254
280
);
255
281
}
256
- $ question ->setValidator (function ($ answer ) use ($ option ) {
257
- $ option ->validate ($ option ->getSelectOptions ()[$ answer ]);
258
- return $ answer ;
259
- });
260
282
} else {
261
283
if ($ option ->isValueRequired ()) {
262
284
$ question = new Question (
@@ -269,13 +291,25 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que
269
291
$ option ->getDefault ()
270
292
);
271
293
}
272
- $ question ->setValidator (function ($ answer ) use ($ option ) {
273
- $ option ->validate ($ answer );
274
- return $ answer ;
275
- });
294
+
276
295
}
277
296
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
+
278
311
$ value = $ helper ->ask ($ input , $ output , $ question );
312
+
279
313
return $ value ;
280
314
}
281
- }
315
+ }
0 commit comments