TYPO3  7.6
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
QuestionHelper Class Reference
Inheritance diagram for QuestionHelper:
Helper HelperInterface SymfonyQuestionHelper

Public Member Functions

 ask (InputInterface $input, OutputInterface $output, Question $question)
 
 setInputStream ($stream)
 
 getInputStream ()
 
 getName ()
 
 doAsk (OutputInterface $output, Question $question)
 
- Public Member Functions inherited from Helper
 setHelperSet (HelperSet $helperSet=null)
 
 getHelperSet ()
 

Protected Member Functions

 writePrompt (OutputInterface $output, Question $question)
 
 writeError (OutputInterface $output,\Exception $error)
 

Private Member Functions

 autocomplete (OutputInterface $output, Question $question, $inputStream)
 
 getHiddenResponse (OutputInterface $output, $inputStream)
 
 validateAttempts ($interviewer, OutputInterface $output, Question $question)
 
 getShell ()
 
 hasSttyAvailable ()
 

Private Attributes

 $inputStream
 

Static Private Attributes

static $shell
 
static $stty
 

Additional Inherited Members

- Static Public Member Functions inherited from Helper
static strlen ($string)
 
static formatTime ($secs)
 
static formatMemory ($memory)
 
static strlenWithoutDecoration (OutputFormatterInterface $formatter, $string)
 
- Protected Attributes inherited from Helper
 $helperSet = null
 

Detailed Description

The QuestionHelper class provides helpers to interact with the user.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 25 of file QuestionHelper.php.

Member Function Documentation

ask ( InputInterface  $input,
OutputInterface  $output,
Question  $question 
)

Asks a question to the user.

Parameters
InputInterface$inputAn InputInterface instance
OutputInterface$outputAn OutputInterface instance
Question$questionThe question to ask
Returns
string The user answer
Exceptions
\RuntimeExceptionIf there is no data to read in the input stream

Definition at line 42 of file QuestionHelper.php.

References QuestionHelper\doAsk(), Question\getDefault(), Question\getValidator(), InputInterface\isInteractive(), and QuestionHelper\validateAttempts().

autocomplete ( OutputInterface  $output,
Question  $question,
  $inputStream 
)
private

Autocompletes a question.

Parameters
OutputInterface$output
Question$question
Returns
string

Definition at line 200 of file QuestionHelper.php.

References QuestionHelper\$inputStream, elseif, Question\getAutocompleterValues(), OutputInterface\getFormatter(), Helper\strlen(), and OutputInterface\write().

Referenced by QuestionHelper\doAsk().

doAsk ( OutputInterface  $output,
Question  $question 
)

Asks the question to the user.

This method is public for PHP 5.3 compatibility, it should be private.

Parameters
OutputInterface$output
Question$question
Returns
bool|mixed|null|string
Exceptions
\Exception
\RuntimeException

Definition at line 110 of file QuestionHelper.php.

References QuestionHelper\$inputStream, QuestionHelper\autocomplete(), Question\getAutocompleterValues(), Question\getDefault(), QuestionHelper\getHiddenResponse(), Question\getNormalizer(), QuestionHelper\hasSttyAvailable(), Question\isHidden(), Question\isHiddenFallback(), Helper\strlen(), and QuestionHelper\writePrompt().

Referenced by QuestionHelper\ask().

getHiddenResponse ( OutputInterface  $output,
  $inputStream 
)
private

Gets a hidden response from user.

Parameters
OutputInterface$outputAn Output instance
Returns
string The answer
Exceptions
\RuntimeExceptionIn case the fallback is deactivated and the response cannot be hidden

Definition at line 319 of file QuestionHelper.php.

References QuestionHelper\$inputStream, QuestionHelper\$shell, QuestionHelper\getShell(), QuestionHelper\hasSttyAvailable(), and OutputInterface\writeln().

Referenced by QuestionHelper\doAsk().

getInputStream ( )

Returns the helper's input stream.

Returns
resource

Definition at line 84 of file QuestionHelper.php.

References QuestionHelper\$inputStream.

getName ( )

{Returns the canonical name of this helper.

Returns
string The canonical name
}

Implements HelperInterface.

Definition at line 92 of file QuestionHelper.php.

getShell ( )
private

Returns a valid unix shell.

Returns
string|bool The valid shell name, false in case no valid shell is found

Definition at line 404 of file QuestionHelper.php.

Referenced by QuestionHelper\getHiddenResponse().

hasSttyAvailable ( )
private

Returns whether Stty is available or not.

Returns
bool

Definition at line 431 of file QuestionHelper.php.

Referenced by QuestionHelper\doAsk(), and QuestionHelper\getHiddenResponse().

setInputStream (   $stream)

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

This is mainly useful for testing purpose.

Parameters
resource$streamThe input stream
Exceptions
\InvalidArgumentExceptionIn case the stream is not a resource

Definition at line 70 of file QuestionHelper.php.

validateAttempts (   $interviewer,
OutputInterface  $output,
Question  $question 
)
private

Validates an attempt.

Parameters
callable$interviewerA callable that will ask for a question and return the result
OutputInterface$outputAn Output instance
Question$questionA Question instance
Returns
string The validated response
Exceptions
\ExceptionIn case the max number of attempts has been reached and no valid response has been given

Definition at line 381 of file QuestionHelper.php.

References Question\getMaxAttempts(), Question\getValidator(), and QuestionHelper\writeError().

Referenced by QuestionHelper\ask().

writeError ( OutputInterface  $output,
\Exception  $error 
)
protected

Outputs an error message.

Parameters
OutputInterface$output
\Exception$error

Definition at line 181 of file QuestionHelper.php.

References Helper\getHelperSet(), and OutputInterface\writeln().

Referenced by QuestionHelper\validateAttempts().

writePrompt ( OutputInterface  $output,
Question  $question 
)
protected

Outputs the question prompt.

Parameters
OutputInterface$output
Question$question

Definition at line 155 of file QuestionHelper.php.

References Question\getQuestion(), OutputInterface\write(), and OutputInterface\writeln().

Referenced by QuestionHelper\doAsk().

Member Data Documentation

$inputStream
private
$shell
staticprivate

Definition at line 28 of file QuestionHelper.php.

Referenced by QuestionHelper\getHiddenResponse().

$stty
staticprivate

Definition at line 29 of file QuestionHelper.php.