8000 Update questionhelper.rst by yceruto · Pull Request #8367 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Update questionhelper.rst #8367
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
8 changes: 8 additions & 0 deletions components/console/helpers/questionhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ will be autocompleted as the user types::
public function execute(InputInterface $input, OutputInterface $output)
{
// ...
$helper = $this->getHelper('question');

$bundles = array('AcmeDemoBundle', 'AcmeBlogBundle', 'AcmeStoreBundle');
$question = new Question('Please enter the name of a bundle', 'FooBundle');
$question->setAutocompleterValues($bundles);
Expand All @@ -192,6 +194,8 @@ convenient for passwords::
public function execute(InputInterface $input, OutputInterface $output)
{
// ...
$helper = $this->getHelper('question');

$question = new Question('What is the database password?');
$question->setHidden(true);
$question->setHiddenFallback(false);
Expand Down Expand Up @@ -225,6 +229,8 @@ method::
public function execute(InputInterface $input, OutputInterface $output)
{
// ...
$helper = $this->getHelper('question');

$question = new Question('Please enter the name of the bundle', 'AppBundle');
$question->setNormalizer(function ($value) {
// $value can be null here
Expand Down Expand Up @@ -256,6 +262,8 @@ method::
public function execute(InputInterface $input, OutputInterface $output)
{
// ...
$helper = $this->getHelper('question');

$question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle');
$question->setValidator(function ($answer) {
if (!is_string($answer) || 'Bundle' !== substr($answer, -6)) {
Expand Down
0