-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[Console] Document timeout functionality for QuestionHelper
#21369
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
Conversation
Setting a Timeout for User Input | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 7.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let move this at the end of this section please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done while merging.
$helper = new QuestionHelper(); | ||
|
||
$question = new Question('Please enter your answer'); | ||
$question->setTimeout(30); // 30 seconds timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$question->setTimeout(30); // 30 seconds timeout | |
$question->setTimeout(seconds: 30); |
would be much better, but lets wait for @xabbuh and @javiereguiluz, because IIRC we don't use named arguments in the docs, as they are not covered by BC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know and I agree. But, it was decided to never show named arguments in docs, so let's not do this. Thanks.
|
||
// ... | ||
$question = new ConfirmationQuestion('Do you want to continue?', false); | ||
$question->setTimeout(10); // 10 seconds timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$question->setTimeout(10); // 10 seconds timeout | |
$question->setTimeout(seconds: 10); |
See comment above
QuestionHelper
b6a3f86
to
c6d70aa
Compare
Thanks Jan for this nice contribution and for adding the docs for it too. |
This adds documentation for the setTimeout() method that was added to the Question class in Symfony 7.4. The timeout feature allows setting a maximum time limit for user input to prevent hanging indefinitely in interactive questions, particularly useful in database transactions or other time-sensitive operations.
Closes #21366