Overview

Namespaces

  • Evenement
  • None
  • Peridot
    • Console
    • Core
    • Reporter
    • Runner
    • Scope
    • Test
  • Symfony
    • Component
      • Console
        • Command
        • Descriptor
        • Event
        • Exception
        • Formatter
        • Helper
        • Input
        • Logger
        • Output
        • Question
        • Style
        • Tester
        • Tests
          • Command
          • Descriptor
          • Fixtures
          • Formatter
          • Helper
          • Input
          • Logger
          • Output
          • Style
          • Tester

Classes

  • DebugFormatterHelper
  • DescriptorHelper
  • DialogHelper
  • FormatterHelper
  • Helper
  • HelperSet
  • InputAwareHelper
  • ProcessHelper
  • ProgressBar
  • ProgressHelper
  • ProgressIndicator
  • QuestionHelper
  • SymfonyQuestionHelper
  • Table
  • TableCell
  • TableHelper
  • TableSeparator
  • TableStyle

Interfaces

  • HelperInterface
  • Overview
  • Namespace
  • Class

Class DialogHelper

The Dialog class provides helpers to interact with the user.

Symfony\Component\Console\Helper\Helper implements Symfony\Component\Console\Helper\HelperInterface
Extended by Symfony\Component\Console\Helper\InputAwareHelper implements Symfony\Component\Console\Input\InputAwareInterface
Extended by Symfony\Component\Console\Helper\DialogHelper
Namespace: Symfony\Component\Console\Helper
Deprecated:

since version 2.5, to be removed in 3.0. Use Symfony\Component\Console\Helper\QuestionHelper instead.


Author: Fabien Potencier fabien@symfony.com
Located at Helper/DialogHelper.php
Methods summary
public
# __construct( $triggerDeprecationError = true )
public integer|string|array
# select( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, array $choices, boolean|string $default = null, boolean|integer $attempts = false, string $errorMessage = 'Value "%s" is invalid', boolean $multiselect = false )

Asks the user to select a value.

Asks the user to select a value.

Parameters

$output
An Output instance
$question
The question to ask
$choices
List of choices to pick from
$default
The default answer if the user enters nothing
$attempts
Max number of times to ask before giving up (false by default, which means infinite)
$errorMessage
Message which will be shown if invalid value from choice list would be picked
$multiselect
Select more than one value separated by comma

Returns

integer|string|array
The selected value or values (the key of the choices array)

Throws

Symfony\Component\Console\Exception\InvalidArgumentException
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
An Output instance
$question
The question to ask
$default
The default answer if none is given by the user
$autocomplete
List of values to autocomplete

Returns

string
The user answer

Throws

Symfony\Component\Console\Exception\RuntimeException
If there is no data to read in the input stream
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

$output
An Output instance
$question
The question to ask
$default
The default answer if the user enters nothing

Returns

boolean
true if the user has confirmed, false otherwise
public string
# askHiddenResponse( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, boolean $fallback = true )

Asks a question to the user, the response is hidden.

Asks a question to the user, the response is hidden.

Parameters

$output
An Output instance
$question
The question
$fallback
In case the response can not be hidden, whether to fallback on non-hidden question or not

Returns

string
The answer

Throws

Symfony\Component\Console\Exception\RuntimeException
In case the fallback is deactivated and the response can not be hidden
public mixed
# askAndValidate( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, callable $validator, integer|false $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
An Output instance
$question
The question to ask
$validator
A PHP callback
$attempts
Max number of times to ask before giving up (false by default, which means infinite)
$default
The default answer if none is given by the user
$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|false $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
An Output instance
$question
The question to ask
$validator
A PHP callback
$attempts
Max number of times to ask before giving up (false by default, which means infinite)
$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
Symfony\Component\Console\Exception\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
The input stream
public resource|null
# getInputStream( )

Returns the helper's input stream.

Returns the helper's input stream.

Returns

resource|null
The input stream or null if the default STDIN is used
public string
# getName( )

Returns the canonical name of this helper.

Returns the canonical name of this helper.

Returns

string
The canonical name
Methods inherited from Symfony\Component\Console\Helper\InputAwareHelper
setInput()
Methods inherited from Symfony\Component\Console\Helper\Helper
formatMemory(), formatTime(), getHelperSet(), setHelperSet(), strlen(), strlenWithoutDecoration()
Properties inherited from Symfony\Component\Console\Helper\InputAwareHelper
$input
Properties inherited from Symfony\Component\Console\Helper\Helper
$helperSet
Peridot API documentation generated by ApiGen