SymfonyComponentConsoleHelperDialogHelper

The Dialog class provides helpers to interact with the user.

Summary

No protected methods found
N/A
No private methods found
N/A
File
vendorSymfonyComponentConsoleHelperDialogHelper.php
Package
Default
Class hierarchy
SymfonyComponentConsoleHelperDialogHelper

Tags

author

Fabien Potencier fabien@symfony.com

Properties

$helperSet

$helperSet : 

Type

Inherited from
SymfonyComponentConsoleHelperHelper

Tags

None found

$inputStream

$inputStream : 

Type

Tags

None found

Methods

setHelperSet()

setHelperSet(\Symfony\Component\Console\Helper\HelperSet  $helperSet = null) 

Sets the helper set associated with this helper.

Parameters

SymfonyComponentConsoleHelperHelperSet $helperSet

A HelperSet instance

Inherited from
SymfonyComponentConsoleHelperHelper

Tags

None found

getHelperSet()

getHelperSet() : \Symfony\Component\Console\Helper\HelperSet

Gets the helper set associated with this helper.

Returns

SymfonyComponentConsoleHelperHelperSet

A HelperSet instance

Inherited from
SymfonyComponentConsoleHelperHelper

Tags

None found

ask()

ask(\Symfony\Component\Console\Output\OutputInterface  $output, string|array  $question, string  $default = null) : string

Asks a question to the user.

Parameters

SymfonyComponentConsoleOutputOutputInterface $output

An Output instance

string|array $question

The question to ask

string $default

The default answer if none is given by the user

Throws

RuntimeException

If there is no data to read in the input stream

Returns

string —

The user answer

Tags

None found

askConfirmation()

askConfirmation(\Symfony\Component\Console\Output\OutputInterface  $output, string|array  $question, Boolean  $default = true) : Boolean

Asks a confirmation to the user.

The question will be asked until the user answers by nothing, yes, or no.

Parameters

SymfonyComponentConsoleOutputOutputInterface $output

An Output instance

string|array $question

The question to ask

Boolean $default

The default answer if the user enters nothing

Returns

Boolean —

true if the user has confirmed, false otherwise

Tags

None found

askAndValidate()

askAndValidate(\Symfony\Component\Console\Output\OutputInterface  $output, string|array  $question, callback  $validator, integer  $attempts = false, string  $default = null) : mixed

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

SymfonyComponentConsoleOutputOutputInterface $output

An Output instance

string|array $question

The question to ask

callback $validator

A PHP callback

integer $attempts

Max number of times to ask before giving up (false by default, which means infinite)

string $default

The default answer if none is given by the user

Throws

Exception

When any of the validators return an error

Returns

mixed

Tags

None found

setInputStream()

setInputStream(resource  $stream) 

Sets the input stream to read from when interacting with the user.

This is mainly useful for testing purpose.

Parameters

resource $stream

The input stream

Tags

None found

getInputStream()

getInputStream() : string

Returns the helper's input stream

Returns

string

Tags

None found

getName()

getName() 

Returns the helper's canonical name.

Tags

None found