trait TaskIO (View source)

Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.

printTaskInfo, printTaskSuccess, and printTaskError are the three primary output methods that tasks are encouraged to use. Tasks should avoid using the IO trait output methods.

Traits

Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.

LoggerAwareTrait

Properties

protected ConfigInterface $config from  ConfigAwareTrait
protected OutputAdapterInterface $outputAdapter from  VerbosityThresholdTrait
protected int $verbosityThreshold from  VerbosityThresholdTrait
protected $output

Methods

$this
setConfig(ConfigInterface $config)

Set the config management object.

ConfigInterface
getConfig()

Get the config management object.

static string
configPrefix()

Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().

static 
configClassIdentifier($classname)

No description

static 
configPostfix()

No description

static 
configure(string $key, mixed $value, ConfigInterface|null $config = null)

No description

mixed|null
getConfigValue(string $key, mixed|null $default = null)

No description

$this
setVerbosityThreshold(int $verbosityThreshold)

Required verbosity level before any TaskIO output will be produced.

int
verbosityThreshold()

No description

bool
hasOutputAdapter()

No description

writeMessage(string $message)

Print a message if the selected verbosity level is over this task's verbosity threshold.

setOutput(OutputInterface $output)

No description

OutputInterface
output()

No description

OutputInterface
stderr()

No description

OutputInterface
getOutput() deprecated

Backwards compatibility

null|LoggerInterface
logger() deprecated

No description

printTaskInfo(string $text, null|array $context = null)

Print information about a task in progress.

printTaskSuccess(string $text, null|array $context = null)

Provide notification that some part of the task succeeded.

printTaskWarning(string $text, null|array $context = null)

Provide notification that there is something wrong, but execution can continue.

printTaskError(string $text, null|array $context = null)

Provide notification that some operation in the task failed, and the task cannot continue.

printTaskDebug($text, null|array $context = null)

Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.

printTaskOutput(string $level, string $text, null|array $context) deprecated

No description

bool
hideTaskProgress()

No description

showTaskProgress(bool $inProgress)

No description

string
formatBytes(int $size, int $precision = 2)

Format a quantity of bytes.

string
getPrintedTaskName(null|object $task = null)

Get the formatted task name for use in task output.

array
getTaskContext(null|array $context = null)

No description

Details

$this setConfig(ConfigInterface $config)

Set the config management object.

Parameters

ConfigInterface $config

Return Value

$this

ConfigInterface getConfig()

Get the config management object.

Return Value

ConfigInterface

static protected string configPrefix()

Any class that uses ConfigAwareTrait SHOULD override this method , and define a prefix for its configuration items. This is usually done in a base class. When used, this method should return a string that ends with a "."; see BaseTask::configPrefix().

Return Value

string

static protected configClassIdentifier($classname)

No description

Parameters

$classname

static protected configPostfix()

No description

static configure(string $key, mixed $value, ConfigInterface|null $config = null)

No description

Parameters

string $key
mixed $value
ConfigInterface|null $config

protected mixed|null getConfigValue(string $key, mixed|null $default = null)

No description

Parameters

string $key
mixed|null $default

Return Value

mixed|null

$this setVerbosityThreshold(int $verbosityThreshold)

Required verbosity level before any TaskIO output will be produced.

e.g. OutputInterface::VERBOSITY_VERBOSE

Parameters

int $verbosityThreshold

Return Value

$this

int verbosityThreshold()

No description

Return Value

int

setOutputAdapter(OutputAdapterInterface $outputAdapter)

No description

Parameters

OutputAdapterInterface $outputAdapter

bool hasOutputAdapter()

No description

Return Value

bool

bool verbosityMeetsThreshold()

No description

Return Value

bool

writeMessage(string $message)

Print a message if the selected verbosity level is over this task's verbosity threshold.

Parameters

string $message

setOutput(OutputInterface $output)

No description

Parameters

OutputInterface $output

protected OutputInterface output()

No description

Return Value

OutputInterface

protected OutputInterface stderr()

No description

Return Value

OutputInterface

protected OutputInterface getOutput() deprecated

deprecated

Backwards compatibility

Return Value

OutputInterface

null|LoggerInterface logger() deprecated

deprecated

No description

Return Value

null|LoggerInterface

protected printTaskInfo(string $text, null|array $context = null)

Print information about a task in progress.

With the Symfony Console logger, NOTICE is displayed at VERBOSITY_VERBOSE and INFO is displayed at VERBOSITY_VERY_VERBOSE.

Robo overrides the default such that NOTICE is displayed at VERBOSITY_NORMAL and INFO is displayed at VERBOSITY_VERBOSE.

n.b. We should probably have printTaskNotice for our ordinary output, and use printTaskInfo for less interesting messages.

Parameters

string $text
null|array $context

protected printTaskSuccess(string $text, null|array $context = null)

Provide notification that some part of the task succeeded.

With the Symfony Console logger, success messages are remapped to NOTICE, and displayed in VERBOSITY_VERBOSE. When used with the Robo logger, success messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskWarning(string $text, null|array $context = null)

Provide notification that there is something wrong, but execution can continue.

Warning messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskError(string $text, null|array $context = null)

Provide notification that some operation in the task failed, and the task cannot continue.

Error messages are displayed at VERBOSITY_NORMAL.

Parameters

string $text
null|array $context

protected printTaskDebug($text, null|array $context = null)

Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.

Parameters

$text
null|array $context

protected printTaskOutput(string $level, string $text, null|array $context) deprecated

deprecated

No description

Parameters

string $level

One of the \Psr\Log\LogLevel constant

string $text
null|array $context

protected bool hideTaskProgress()

No description

Return Value

bool

protected showTaskProgress(bool $inProgress)

No description

Parameters

bool $inProgress

protected string formatBytes(int $size, int $precision = 2)

Format a quantity of bytes.

Parameters

int $size
int $precision

Return Value

string

protected string getPrintedTaskName(null|object $task = null)

Get the formatted task name for use in task output.

This is placed in the task context under 'name', and used as the log label by Robo\Common\RoboLogStyle, which is inserted at the head of log messages by Robo\Common\CustomLogStyle::formatMessage().

Parameters

null|object $task

Return Value

string

protected array getTaskContext(null|array $context = null)

No description

Parameters

null|array $context

Return Value

array

Context information.