Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • DialogHelper
  • FormatterHelper
  • Helper
  • HelperSet
  • ProgressHelper

Interfaces

  • HelperInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

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\DialogHelper
Namespace: Symfony\Component\Console\Helper
Author: Fabien Potencier <fabien@symfony.com>
Located at console/Symfony/Component/Console/Helper/DialogHelper.php
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

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
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

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
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
$question
string|array
$question The question to ask
$default
Boolean
$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
Symfony\Component\Console\Output\OutputInterface
$output An Output instance
$question
string|array
$question The question
$fallback
Boolean
$fallback In case the response can not be hidden, whether to fallback on non-hidden question or not

Returns

string
The answer

Throws

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 $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
Methods inherited from Symfony\Component\Console\Helper\Helper
getHelperSet(), setHelperSet()
Properties inherited from Symfony\Component\Console\Helper\Helper
$helperSet
php-coveralls API documentation generated by ApiGen 2.8.0