‪TYPO3CMS  9.5
TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput Class Reference

Public Member Functions

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

Protected Member Functions

ArgvInput getInput ()
 
QuestionHelper getQuestionHelper ()
 
ProgressBar getProgressBar ()
 
Table getTable ()
 

Protected Attributes

ArgvInput $input
 
SymfonyConsoleOutput $output
 
QuestionHelper $questionHelper
 
ProgressBar $progressBar
 
Table $table
 

Detailed Description

A wrapper for Symfony ConsoleOutput and related helpers

Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. Use symfony/console commands instead.

Definition at line 33 of file ConsoleOutput.php.

Constructor & Destructor Documentation

◆ __construct()

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

Creates and initializes the Symfony I/O instances

Definition at line 58 of file ConsoleOutput.php.

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

Member Function Documentation

◆ ask()

string TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::ask (   $question,
  $default = null,
array  $autocomplete = null 
)

Asks a question to the user

Parameters
string | array$question‪The question to ask. If an array each array item is turned into one line of a multi-line question
string$default‪The default answer if none is given by the user
array$autocomplete‪List of values to autocomplete. This only works if "stty" is installed
Returns
‪string The user answer
Exceptions

Definition at line 171 of file ConsoleOutput.php.

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

◆ askAndValidate()

mixed TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::askAndValidate (   $question,
  $validator,
  $attempts = null,
  $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$question‪The question to ask. If an array each array item is turned into one line of a multi-line question
callable$validator‪A PHP callback that gets a value and is expected to return the (transformed) value or throw an exception if it wasn't valid
int | null$attempts‪Max number of times to ask before giving up (null by default, which means infinite)
string$default‪The default answer if none is given by the user
array$autocomplete‪List of values to autocomplete. This only works if "stty" is installed
Returns
‪mixed
Exceptions

Definition at line 227 of file ConsoleOutput.php.

References $validator, TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getInput(), TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getQuestionHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ askConfirmation()

bool 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$question‪The question to ask. If an array each array item is turned into one line of a multi-line question
bool$default‪The default answer if the user enters nothing
Returns
‪bool true if the user has confirmed, false otherwise

Definition at line 188 of file ConsoleOutput.php.

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

◆ askHiddenResponse()

string TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::askHiddenResponse (   $question,
  $fallback = true 
)

Asks a question to the user, the response is hidden

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

Definition at line 203 of file ConsoleOutput.php.

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

◆ askHiddenResponseAndValidate()

string 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$question‪The question to ask. If an array each array item is turned into one line of a multi-line question
callable$validator‪A 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$attempts‪Max number of times to ask before giving up (false by default, which means infinite)
bool$fallback‪In case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
‪string The response
Exceptions

Definition at line 252 of file ConsoleOutput.php.

References $validator, TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getInput(), TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getQuestionHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

◆ getInput()

◆ getMaximumLineLength()

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

Returns the desired maximum line length for console output.

Returns
‪int

Definition at line 73 of file ConsoleOutput.php.

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

◆ getProgressBar()

ProgressBar TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::getProgressBar ( )
protected

◆ getQuestionHelper()

◆ getTable()

Table TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::getTable ( )
protected

Returns or initializes the symfony/console Table

Returns
‪Table

Definition at line 352 of file ConsoleOutput.php.

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

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$text‪Text to output
array$arguments‪Optional arguments to use for sprintf
int$leftPadding‪The number of spaces to use for indentation
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$text‪Text to output
array$arguments‪Optional arguments to use for sprintf
See also
output()
‪outputLines()

Definition at line 102 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\$table, and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getTable().

◆ progressAdvance()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::progressAdvance (   $step = 1)

Advances the progress output X steps

Parameters
int$step‪Number of steps to advance
Exceptions

Definition at line 279 of file ConsoleOutput.php.

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

◆ progressFinish()

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

Finishes the progress output

Definition at line 298 of file ConsoleOutput.php.

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

◆ progressSet()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::progressSet (   $current)

Sets the current progress

Parameters
int$current‪The current progress
Exceptions

Definition at line 290 of file ConsoleOutput.php.

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

◆ progressStart()

TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::progressStart (   $max = null)

Starts the progress output

Parameters
int$max‪Maximum steps. If NULL an indeterminate progress bar is rendered

Definition at line 268 of file ConsoleOutput.php.

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

◆ select()

int string array TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::select (   $question,
  $choices,
  $default = null,
  $multiSelect = false,
  $attempts = null 
)

Asks the user to select a value

Parameters
string | array$question‪The question to ask. If an array each array item is turned into one line of a multi-line question
array$choices‪List of choices to pick from
bool$default‪The default answer if the user enters nothing
bool$multiSelect‪If TRUE the result will be an array with the selected options. Multiple options can be given separated by commas
int | null$attempts‪Max number of times to ask before giving up (null 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\getInput(), TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\getQuestionHelper(), and TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput\output().

Member Data Documentation

◆ $input

ArgvInput TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$input
protected

Definition at line 37 of file ConsoleOutput.php.

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

◆ $output

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

Definition at line 41 of file ConsoleOutput.php.

◆ $progressBar

ProgressBar TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$progressBar
protected

◆ $questionHelper

QuestionHelper TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$questionHelper
protected

◆ $table

Table TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput::$table
protected