File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/Symfony/Component/Console/Question Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1818 */
1919class ConfirmationQuestion extends Question
2020{
21- public function __construct ($ question , $ default = true )
21+ private $ trueAnswer ;
22+
23+ public function __construct ($ question , $ default = true , $ trueAnswer = 'y ' )
2224 {
2325 parent ::__construct ($ question , (bool ) $ default );
2426
2527 $ this ->setNormalizer ($ this ->getDefaultNormalizer ());
28+
29+ $ this ->trueAnswer = strtolower ($ trueAnswer );
2630 }
2731
2832 private function getDefaultNormalizer ()
@@ -34,11 +38,12 @@ private function getDefaultNormalizer()
3438 return $ answer ;
3539 }
3640
41+ $ answerIsTrue = $ this ->trueAnswer === strtolower (substr ($ answer , 0 , strlen ($ this ->trueAnswer )));
3742 if (false === $ default ) {
38- return $ answer && ' y ' === strtolower ( $ answer [ 0 ]) ;
43+ return $ answer && $ answerIsTrue ;
3944 }
4045
41- return !$ answer || ' y ' === strtolower ( $ answer [ 0 ]) ;
46+ return !$ answer || $ answerIsTrue ;
4247 };
4348 }
4449}
You can’t perform that action at this time.
0 commit comments