@@ -169,6 +169,14 @@ protected function initialize(InputInterface $input, OutputInterface $output)
169169 }
170170 }
171171
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+
172180 $ errors = $ this ->configModel ->validate ($ configOptionsToValidate );
173181 $ errors = array_merge ($ errors , $ this ->adminUser ->validate ($ input ));
174182 $ errors = array_merge ($ errors , $ this ->validate ($ input ));
@@ -226,6 +234,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
226234 );
227235 }
228236
237+ $ output ->writeln ("" );
238+
229239 foreach ($ this ->userConfig ->getOptionsList () as $ option ) {
230240 $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
231241 $ input ,
@@ -235,6 +245,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
235245 );
236246 }
237247
248+ $ output ->writeln ("" );
249+
238250 foreach ($ this ->adminUser ->getOptionsList () as $ option ) {
239251 $ configOptionsToValidate [$ option ->getName ()] = $ this ->askQuestion (
240252 $ input ,
@@ -243,7 +255,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
243255 $ option
244256 );
245257 }
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 ;
247269 }
248270
249271 /**
@@ -265,7 +287,7 @@ private function askQuestion(
265287 $ option ,
266288 $ validateInline = false
267289 ) {
268- if (get_class ( $ option) === ' Magento\Framework\Setup\Option\SelectConfigOption ' ) {
290+ if ($ option instanceof \ Magento \Framework \Setup \Option \SelectConfigOption) {
269291 if ($ option ->isValueRequired ()) {
270292 $ question = new ChoiceQuestion (
271293 $ option ->getDescription () . '? ' ,
@@ -291,16 +313,20 @@ private function askQuestion(
291313 $ option ->getDefault ()
292314 );
293315 }
294-
295316 }
296317
297318 $ question ->setValidator (function ($ answer ) use ($ option , $ validateInline ) {
298- $ answer = trim ($ answer );
299319
300- if (get_class ( $ option) === ' Magento\Framework\Setup\Option\SelectConfigOption ' ) {
320+ if ($ option instanceof \ Magento \Framework \Setup \Option \SelectConfigOption) {
301321 $ answer = $ option ->getSelectOptions ()[$ answer ];
302322 }
303323
324+ if ($ answer == null ) {
325+ $ answer = '' ;
326+ } else {
327+ $ answer = trim ($ answer );
328+ }
329+
304330 if ($ validateInline ) {
305331 $ option ->validate ($ answer );
306332 }
@@ -312,4 +338,4 @@ private function askQuestion(
312338
313339 return $ value ;
314340 }
315- }
341+ }
0 commit comments