ProcessExecutor
class ProcessExecutor implements ConfigAwareInterface, LoggerAwareInterface, OutputAwareInterface, VerbosityThresholdInterface (View source)
Traits
Class ExecTrait
Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.
Task input/output methods. TaskIO is 'used' in BaseTask, so any task that extends this class has access to all of the methods here.
Properties
protected bool | $background | from ExecTrait | |
protected null|int | $timeout | from ExecTrait | |
protected null|int | $idleTimeout | from ExecTrait | |
protected null|array | $env | from ExecTrait | |
protected Process | $process | from ExecTrait | |
protected resource|string | $input | from ExecTrait | |
protected bool | $interactive | from ExecTrait | |
protected bool | $isPrinted | from ExecTrait | |
protected bool | $isMetadataPrinted | from ExecTrait | |
protected string | $workingDirectory | from ExecTrait | |
protected ConfigInterface | $config | from ConfigAwareTrait | |
protected OutputAdapterInterface | $outputAdapter | from VerbosityThresholdTrait | |
protected int | $verbosityThreshold | from VerbosityThresholdTrait | |
protected OutputInterface | $output | from OutputAwareTrait | |
protected TimeKeeper|null | $timer | from Timer | |
protected null|ProgressIndicator | $progressIndicator | from ProgressIndicatorAwareTrait |
Methods
{@inheritdoc}
Print information about a task in progress.
Print a message if the selected verbosity level is over this task's verbosity threshold.
Executes command in background mode (asynchronously)
Stops command if it does not output something for a while
Set a single environment variable, or multiple.
Pass an input to the process. Can be resource created with fopen() or string
Pass an input to the process. Can be resource created with fopen() or string
Attach tty to process for interactive input
Shortcut for setting isPrinted() and isMetadataPrinted() to false.
Should command metadata be printed. I,e., command and timer.
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().
No description
No description
Required verbosity level before any TaskIO output will be produced.
Provide notification that some part of the task succeeded.
Provide notification that there is something wrong, but execution can continue.
Provide notification that some operation in the task failed, and the task cannot continue.
Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.
Get the formatted task name for use in task output.
No description
No description
No description
Details
protected
getCommandDescription()
{@inheritdoc}
in
Timer at line 12
protected
startTimer()
No description
in
Timer at line 20
protected
stopTimer()
No description
in
Timer at line 36
protected float|null
getExecutionTime()
No description
protected bool
hideTaskProgress()
No description
protected
showTaskProgress(bool $inProgress)
No description
in
TaskIO at line 85
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.
bool
verbosityMeetsThreshold()
No description
writeMessage(string $message)
Print a message if the selected verbosity level is over this task's verbosity threshold.
$this
detectInteractive()
Sets $this->interactive() based on posix_isatty().
$this
background(bool $arg = true)
Executes command in background mode (asynchronously)
$this
timeout(int $timeout)
Stop command if it runs longer then $timeout in seconds
$this
idleTimeout(int $timeout)
Stops command if it does not output something for a while
$this
env(string|array $env, bool|string $value = null)
Set a single environment variable, or multiple.
$this
envVars(array $env)
Sets the environment variables for the command
$this
setProcessInput(resource|string $input)
Pass an input to the process. Can be resource created with fopen() or string
$this
setInput(resource|string $input)
deprecated
deprecated
Pass an input to the process. Can be resource created with fopen() or string
$this
interactive(bool $interactive = true)
Attach tty to process for interactive input
bool
getPrinted()
Is command printing its output to screen
$this
dir(string $dir)
Changes working directory of command
$this
silent(bool $arg)
Shortcut for setting isPrinted() and isMetadataPrinted() to false.
$this
printed(bool $arg)
deprecated
deprecated
Should command output be printed
$this
printOutput(bool $arg)
Should command output be printed
$this
printMetadata(bool $arg)
Should command metadata be printed. I,e., command and timer.
protected ResultData
execute(Process $process, callable $output_callback = null)
No description
protected
stop()
No description
protected
printAction(array $context = [])
No description
protected string
formatCommandDisplay(string $command)
No description
protected array
getResultData()
Gets the data array to be passed to Result().
$this
setConfig(ConfigInterface $config)
Set the config management object.
ConfigInterface
getConfig()
Get the config management object.
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().
static protected
configClassIdentifier($classname)
No description
static protected
configPostfix()
No description
static
configure(string $key, mixed $value, ConfigInterface|null $config = null)
No description
protected 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.
e.g. OutputInterface::VERBOSITY_VERBOSE
int
verbosityThreshold()
No description
setOutputAdapter(OutputAdapterInterface $outputAdapter)
No description
OutputAdapterInterface
outputAdapter()
No description
bool
hasOutputAdapter()
No description
$this
setOutput(OutputInterface $output)
No description
protected OutputInterface
output()
No description
protected OutputInterface
stderr()
No description
protected OutputInterface
getOutput()
deprecated
deprecated
Backwards compatibility
in
TaskIO at line 49
null|LoggerInterface
logger()
deprecated
deprecated
No description
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.
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.
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.
protected
printTaskDebug($text, null|array $context = null)
Provide debugging notification. These messages are only displayed if the log level is VERBOSITY_DEBUG.
protected
printTaskOutput(string $level, string $text, null|array $context)
deprecated
deprecated
No description
protected string
formatBytes(int $size, int $precision = 2)
Format a quantity of bytes.
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().
protected array
getTaskContext(null|array $context = null)
No description
in
Timer at line 28
protected
resetTimer()
No description
int
progressIndicatorSteps()
No description
$this
setProgressIndicator(null|ProgressIndicator $progressIndicator)
No description
protected null|bool
hideProgressIndicator()
No description
protected
showProgressIndicator()
No description
protected
restoreProgressIndicator(bool $visible)
No description
protected int
getTotalExecutionTime()
No description
protected
startProgressIndicator()
No description
protected bool
inProgress()
No description
protected
stopProgressIndicator()
No description
protected
disableProgressIndicator()
No description
protected
detatchProgressIndicator()
No description
protected
advanceProgressIndicator(int $steps = 1)
No description
__construct(Process $process)
No description
static ProcessExecutor
create(ContainerInterface $container, Process $process)
No description
run()
No description