Methods summary
public
integer|string
|
#
select( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, array $choices, Boolean $default = null, Boolean|integer $attempts = false, string $errorMessage = 'Value "%s" is invalid' )
Asks the user to select a value.
Asks the user to select a value.
Parameters
- $output
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
- $question
string|array $question The question to ask
- $choices
array $choices List of choices to pick from
- $default
Boolean $default The default answer if the user enters nothing
- $attempts
Boolean|integer $attempts Max number of times to ask before giving up (false by default, which
means infinite)
- $errorMessage
string $errorMessage Message which will be shown if invalid value from choice list
would be picked
Returns
integer|string The selected value (the key of the choices array)
Throws
|
public
string
|
#
ask( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, string $default = null, array $autocomplete = null )
Asks a question to the user.
Asks a question to the user.
Parameters
- $output
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
- $question
string|array $question The question to ask
- $default
string $default The default answer if none is given by the user
- $autocomplete
array $autocomplete List of values to autocomplete
Returns
string The user answer
Throws
|
public
Boolean
|
#
askConfirmation( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, Boolean $default = true )
Asks a confirmation to the user.
Asks a confirmation to the user.
The question will be asked until the user answers by nothing, yes, or no.
Parameters
Returns
Boolean true if the user has confirmed, false otherwise
|
public
string
|
|
public
mixed
|
#
askAndValidate( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, callable $validator, integer $attempts = false, string $default = null, array $autocomplete = null )
Asks for a value and validates the response.
Asks for a value and validates the response.
The validator receives the data to validate. It must return the validated
data when the data is valid and throw an exception otherwise.
Parameters
- $output
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
- $question
string|array $question The question to ask
- $validator
callable $validator A PHP callback
- $attempts
integer $attempts Max number of times to ask before giving up (false by default, which
means infinite)
- $default
string $default The default answer if none is given by the user
- $autocomplete
array $autocomplete List of values to autocomplete
Returns
mixed
Throws
Exception
When any of the validators return an error
|
public
string
|
#
askHiddenResponseAndValidate( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, callable $validator, integer $attempts = false, Boolean $fallback = true )
Asks for a value, hide and validates the response.
Asks for a value, hide and validates the response.
The validator receives the data to validate. It must return the validated
data when the data is valid and throw an exception otherwise.
Parameters
- $output
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
- $question
string|array $question The question to ask
- $validator
callable $validator A PHP callback
- $attempts
integer $attempts Max number of times to ask before giving up (false by default, which
means infinite)
- $fallback
Boolean $fallback In case the response can not be hidden, whether to fallback on
non-hidden question or not
Returns
string The response
Throws
Exception
When any of the validators return an error
RuntimeException
In case the fallback is deactivated and the response can not be hidden
|
public
|
#
setInputStream( resource $stream )
Sets the input stream to read from when interacting with the user.
Sets the input stream to read from when interacting with the user.
This is mainly useful for testing purpose.
Parameters
- $stream
resource $stream The input stream
|
public
string
|
#
getInputStream( )
Returns the helper's input stream
Returns the helper's input stream
Returns
string
|
public
string
|
#
getName( )
Returns the canonical name of this helper.
Returns the canonical name of this helper.
Returns
string The canonical name
|