@@ -169,6 +169,14 @@ protected function initialize(InputInterface $input, OutputInterface $output)
169
169
}
170
170
}
171
171
172
+ if ($ inputOptions ['interactive ' ]) {
173
+ $ command = '' ;
174
+ foreach ($ configOptionsToValidate as $ key => $ value ) {
175
+ $ command .= " -- {$ key }= {$ value }" ;
176
+ }
177
+ $ output ->writeln ("<comment>Try re-running command: php bin/magento setup:install {$ command }</comment> " );
178
+ }
179
+
172
180
$ errors = $ this ->configModel ->validate ($ configOptionsToValidate );
173
181
$ errors = array_merge ($ errors , $ this ->adminUser ->validate ($ input ));
174
182
$ errors = array_merge ($ errors , $ this ->validate ($ input ));
@@ -226,6 +234,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
226
234
);
227
235
}
228
236
237
+ $ output ->writeln ("" );
238
+
229
239
foreach ($ this ->userConfig ->getOptionsList () as $ option ) {
230
240
$ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
231
241
$ input ,
@@ -235,6 +245,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
235
245
);
236
246
}
237
247
248
+ $ output ->writeln ("" );
249
+
238
250
foreach ($ this ->adminUser ->getOptionsList () as $ option ) {
239
251
$ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
240
252
$ input ,
@@ -243,7 +255,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
243
255
$ option
244
256
);
245
257
}
246
- return $ configOptionsToValidate ;
258
+
259
+ $ output ->writeln ("" );
260
+
261
+ $ returnConfigOptionsToValidate = [];
262
+ foreach ($ configOptionsToValidate as $ key => $ value ) {
263
+ if ($ value != '' ) {
264
+ $ returnConfigOptionsToValidate [$ key ] = $ value ;
265
+ }
266
+ }
267
+
268
+ return $ returnConfigOptionsToValidate ;
247
269
}
248
270
249
271
/**
@@ -265,7 +287,7 @@ private function askQuestion(
265
287
$ option ,
266
288
$ validateInline = false
267
289
) {
268
- if (get_class ( $ option) === ' Magento\Framework\Setup\Option\SelectConfigOption ' ) {
290
+ if ($ option instanceof \ Magento \Framework \Setup \Option \SelectConfigOption) {
269
291
if ($ option ->isValueRequired ()) {
270
292
$ question = new ChoiceQuestion (
271
293
$ option ->getDescription () . '? ' ,
@@ -291,16 +313,20 @@ private function askQuestion(
291
313
$ option ->getDefault ()
292
314
);
293
315
}
294
-
295
316
}
296
317
297
318
$ question ->setValidator (function ($ answer ) use ($ option , $ validateInline ) {
298
- $ answer = trim ($ answer );
299
319
300
- if (get_class ( $ option) === ' Magento\Framework\Setup\Option\SelectConfigOption ' ) {
320
+ if ($ option instanceof \ Magento \Framework \Setup \Option \SelectConfigOption) {
301
321
$ answer = $ option ->getSelectOptions ()[$ answer ];
302
322
}
303
323
324
+ if ($ answer == null ) {
325
+ $ answer = '' ;
326
+ } else {
327
+ $ answer = trim ($ answer );
328
+ }
329
+
304
330
if ($ validateInline ) {
305
331
$ option ->validate ($ answer );
306
332
}
@@ -312,4 +338,4 @@ private function askQuestion(
312
338
313
339
return $ value ;
314
340
}
315
- }
341
+ }
0 commit comments