TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput Class Reference

Public Member Functions

 __construct ()
 
 getMaximumLineLength ()
 
 output ($text, array $arguments=[])
 
 outputLine ($text='', array $arguments=[])
 
 outputFormatted ($text='', array $arguments=[], $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 ConsoleOutput.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::__construct ( )

Creates and initializes the SymfonyConsoleOutput instance

Returns
void

Definition at line 55 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

Member Function Documentation

◆ ask()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 166 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ askAndValidate()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 213 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ askConfirmation()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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 ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ askHiddenResponse()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 193 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ askHiddenResponseAndValidate()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 233 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ getDialogHelper()

◆ getMaximumLineLength()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::getMaximumLineLength ( )

Returns the desired maximum line length for console output.

Returns
int

Definition at line 70 of file ConsoleOutput.php.

Referenced by TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\outputFormatted().

◆ getProgressHelper()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::getProgressHelper ( )
protected

◆ getTableHelper()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::getTableHelper ( )
protected

Returns or initializes the symfony/console TableHelper

Returns
TableHelper

Definition at line 318 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\$tableHelper.

Referenced by TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\outputTable().

◆ output()

◆ outputFormatted()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::outputFormatted (   $text = '',
array  $arguments = [],
  $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 ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getMaximumLineLength(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\outputLine().

◆ outputLine()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::outputLine (   $text = '',
array  $arguments = [] 
)

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 ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

Referenced by TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\outputFormatted().

◆ outputTable()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::outputTable (   $rows,
  $headers = null 
)

Renders a table like output of the given $rows

Parameters
array$rows
array$headers

Definition at line 131 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\$tableHelper, TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getTableHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ progressAdvance()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 257 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getProgressHelper().

◆ progressFinish()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::progressFinish ( )

Finishes the progress output

Returns
void

Definition at line 280 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getProgressHelper().

◆ progressSet()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::progressSet (   $current,
  $redraw = false 
)

Sets the current progress

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

Definition at line 270 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getProgressHelper().

◆ progressStart()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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 ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getProgressHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ select()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::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

Definition at line 152 of file ConsoleOutput.php.

References TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getDialogHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

Member Data Documentation

◆ $dialogHelper

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$dialogHelper
protected

◆ $output

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$output
protected

Definition at line 33 of file ConsoleOutput.php.

◆ $progressHelper

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$progressHelper
protected

◆ $tableHelper

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$tableHelper
protected