TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ConsoleOutput Class Reference

Public Member Functions

 __construct ()
 
 getMaximumLineLength ()
 
 output ($text, array $arguments=array())
 
 outputLine ($text= '', array $arguments=array())
 
 outputFormatted ($text= '', array $arguments=array(), $leftPadding=0)
 
 outputTable ($rows, $headers=null)
 
 select ($question, $choices, $default=null, $multiSelect=false, $attempts=false)
 
 ask ($question, $default=null, array $autocomplete=null)
 
 askConfirmation ($question, $default=true)
 
 askHiddenResponse ($question, $fallback=true)
 
 askAndValidate ($question, $validator, $attempts=false, $default=null, array $autocomplete=null)
 
 askHiddenResponseAndValidate ($question, $validator, $attempts=false, $fallback=true)
 
 progressStart ($max=null)
 
 progressAdvance ($step=1, $redraw=false)
 
 progressSet ($current, $redraw=false)
 
 progressFinish ()
 

Protected Member Functions

 getDialogHelper ()
 
 getProgressHelper ()
 
 getTableHelper ()
 

Protected Attributes

 $output
 
 $dialogHelper
 
 $progressHelper
 
 $tableHelper
 

Detailed Description

A wrapper for Symfony ConsoleOutput and related helpers

Definition at line 28 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

Constructor & Destructor Documentation

__construct ( )

Creates and initializes the SymfonyConsoleOutput instance

Returns
void

Definition at line 55 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\output().

Member Function Documentation

ask (   $question,
  $default = null,
array  $autocomplete = null 
)

Asks a question to the user

Parameters
string | array$questionThe question to ask. If an array each array item is turned into one line of a multi-line question
string$defaultThe default answer if none is given by the user
array$autocompleteList of values to autocomplete. This only works if "stty" is installed
Returns
string The user answer
Exceptions
\RuntimeExceptionIf there is no data to read in the input stream

Definition at line 166 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

askAndValidate (   $question,
  $validator,
  $attempts = false,
  $default = null,
array  $autocomplete = null 
)

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
string | array$questionThe question to ask. If an array each array item is turned into one line of a multi-line question
callable$validatorA PHP callback that gets a value and is expected to return the (transformed) value or throw an exception if it wasn't valid
int | bool$attemptsMax number of times to ask before giving up (false by default, which means infinite)
string$defaultThe default answer if none is given by the user
array$autocompleteList of values to autocomplete. This only works if "stty" is installed
Returns
mixed
Exceptions
\ExceptionWhen any of the validators return an error

Definition at line 213 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

askConfirmation (   $question,
  $default = true 
)

Asks a confirmation to the user.

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

Parameters
string | array$questionThe question to ask. If an array each array item is turned into one line of a multi-line question
bool$defaultThe default answer if the user enters nothing
Returns
bool true if the user has confirmed, false otherwise

Definition at line 180 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

askHiddenResponse (   $question,
  $fallback = true 
)

Asks a question to the user, the response is hidden

Parameters
string | array$questionThe question. If an array each array item is turned into one line of a multi-line question
bool$fallbackIn case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
string The answer
Exceptions
\RuntimeExceptionIn case the fallback is deactivated and the response can not be hidden

Definition at line 193 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

askHiddenResponseAndValidate (   $question,
  $validator,
  $attempts = false,
  $fallback = true 
)

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
string | array$questionThe question to ask. If an array each array item is turned into one line of a multi-line question
callable$validatorA PHP callback that gets a value and is expected to return the (transformed) value or throw an exception if it wasn't valid
int | bool$attemptsMax number of times to ask before giving up (false by default, which means infinite)
bool$fallbackIn case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
string The response
Exceptions
\ExceptionWhen any of the validators return an error
\RuntimeExceptionIn case the fallback is deactivated and the response can not be hidden

Definition at line 233 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

getDialogHelper ( )
protected
getMaximumLineLength ( )

Returns the desired maximum line length for console output.

Returns
int

Definition at line 70 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

Referenced by ConsoleOutput\outputFormatted().

getProgressHelper ( )
protected

Returns or initializes the symfony/console ProgressHelper

Returns
ProgressHelper

Definition at line 305 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\$progressHelper.

Referenced by ConsoleOutput\progressAdvance(), ConsoleOutput\progressFinish(), ConsoleOutput\progressSet(), and ConsoleOutput\progressStart().

getTableHelper ( )
protected

Returns or initializes the symfony/console TableHelper

Returns
TableHelper

Definition at line 318 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\$tableHelper.

Referenced by ConsoleOutput\outputTable().

output (   $text,
array  $arguments = array() 
)

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

See Also
http://www.php.net/sprintf
Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
Returns
void

Definition at line 84 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

Referenced by ConsoleOutput\__construct(), ConsoleOutput\ask(), ConsoleOutput\askAndValidate(), ConsoleOutput\askConfirmation(), ConsoleOutput\askHiddenResponse(), ConsoleOutput\askHiddenResponseAndValidate(), ConsoleOutput\outputLine(), ConsoleOutput\outputTable(), ConsoleOutput\progressStart(), and ConsoleOutput\select().

outputFormatted (   $text = '',
array  $arguments = array(),
  $leftPadding = 0 
)

Formats the given text to fit into the maximum line length and outputs it to the console window

Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
int$leftPaddingThe number of spaces to use for indentation
Returns
void
See Also
outputLine()

Definition at line 116 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getMaximumLineLength(), and ConsoleOutput\outputLine().

outputLine (   $text = '',
array  $arguments = array() 
)

Outputs specified text to the console window and appends a line break

Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
Returns
void
See Also
output()
outputLines()

Definition at line 101 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\output().

Referenced by ConsoleOutput\outputFormatted().

outputTable (   $rows,
  $headers = null 
)

Renders a table like output of the given $rows

Parameters
array$rows
array$headers

Definition at line 131 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\$tableHelper, ConsoleOutput\getTableHelper(), and ConsoleOutput\output().

progressAdvance (   $step = 1,
  $redraw = false 
)

Advances the progress output X steps

Parameters
int$stepNumber of steps to advance
bool$redrawWhether to redraw or not
Returns
void
Exceptions
\LogicException

Definition at line 257 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getProgressHelper().

progressFinish ( )

Finishes the progress output

Returns
void

Definition at line 280 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getProgressHelper().

progressSet (   $current,
  $redraw = false 
)

Sets the current progress

Parameters
int$currentThe current progress
bool$redrawWhether to redraw or not
Returns
void
Exceptions
\LogicException

Definition at line 270 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getProgressHelper().

progressStart (   $max = null)

Starts the progress output

Parameters
int$maxMaximum steps. If NULL an indeterminate progress bar is rendered
Returns
void

Definition at line 244 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getProgressHelper(), and ConsoleOutput\output().

select (   $question,
  $choices,
  $default = null,
  $multiSelect = false,
  $attempts = false 
)

Asks the user to select a value

Parameters
string | array$questionThe question to ask. If an array each array item is turned into one line of a multi-line question
array$choicesList of choices to pick from
bool$defaultThe default answer if the user enters nothing
bool$multiSelectIf TRUE the result will be an array with the selected options. Multiple options can be given separated by commas
bool | int$attemptsMax number of times to ask before giving up (false by default, which means infinite)
Returns
int|string|array The selected value or values (the key of the choices array)
Exceptions
\InvalidArgumentException

Definition at line 152 of file typo3/sysext/extbase/Classes/Mvc/Cli/ConsoleOutput.php.

References ConsoleOutput\getDialogHelper(), and ConsoleOutput\output().

Member Data Documentation

$dialogHelper
protected
$output
protected
$progressHelper
protected
$tableHelper
protected