Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcb4f09

Browse files
committed
Fixed SymfonyQuestionHelper multi-choice with defaults
1 parent14d48a1 commitbcb4f09

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ protected function writePrompt(OutputInterface $output, Question $question)
6767

6868
break;
6969

70+
case$questioninstanceof ChoiceQuestion &&$question->isMultiSelect():
71+
$choices =$question->getChoices();
72+
$default =explode(',',$default);
73+
74+
foreach ($defaultas &$defaultVal) {
75+
$defaultVal =$choices[$defaultVal];
76+
}
77+
78+
unset($defaultVal);
79+
80+
$text =sprintf(' <info>%s</info> [<comment>%s</comment>]:',$text,implode(',',$default));
81+
82+
break;
83+
7084
case$questioninstanceof ChoiceQuestion:
7185
$choices =$question->getChoices();
7286
$text =sprintf(' <info>%s</info> [<comment>%s</comment>]:',$text,$choices[$default]);

‎src/Symfony/Component/Console/Question/ChoiceQuestion.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ public function setMultiselect($multiselect)
6868
return$this;
6969
}
7070

71+
/**
72+
* Returns whether the choices are multiselect.
73+
*
74+
* @return bool
75+
*/
76+
publicfunctionisMultiselect()
77+
{
78+
return$this->multiselect;
79+
}
80+
7181
/**
7282
* Gets the prompt for choices.
7383
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp