class ResultWriter (View source)

Write the results of a command. Inject your ResultWriter into the CommandProcessor.

Properties

protected $formatterManager

var FormatterManager

protected callable $displayErrorFunction

Methods

setFormatterManager(FormatterManager $formatterManager)

No description

formatterManager()

Return the formatter manager

setDisplayErrorFunction(callable $fn)

No description

handle(OutputInterface $output, $result, CommandData $commandData, $statusCodeDispatcher = null, $extractDispatcher = null)

Handle the result output and status code calculation.

dataCanBeFormatted($structuredOutput)

No description

string
getFormat(FormatterOptions $options)

Determine the formatter that should be used to render output.

chooseOutputStream(OutputInterface $output, $status)

Determine whether we should use stdout or stderr.

writeUsingFormatter(OutputInterface $output, $structuredOutput, CommandData $commandData, $status = 0)

Call the formatter to output the provided data.

type
writeErrorMessage(OutputInterface $output, int $status, string $structuredOutput, mixed $originalResult)

Description

writeCommandOutput(OutputInterface $output, $structuredOutput, $status = 0)

If the result object is a string, then print it.

interpretStatusCode($status)

If a status code was set, then return it; otherwise, presume success.

Details

setFormatterManager(FormatterManager $formatterManager)

No description

Parameters

FormatterManager $formatterManager

FormatterManager formatterManager()

Return the formatter manager

Return Value

FormatterManager

setDisplayErrorFunction(callable $fn)

No description

Parameters

callable $fn

handle(OutputInterface $output, $result, CommandData $commandData, $statusCodeDispatcher = null, $extractDispatcher = null)

Handle the result output and status code calculation.

Parameters

OutputInterface $output
$result
CommandData $commandData
$statusCodeDispatcher
$extractDispatcher

protected dataCanBeFormatted($structuredOutput)

No description

Parameters

$structuredOutput

protected string getFormat(FormatterOptions $options)

Determine the formatter that should be used to render output.

If the user specified a format via the --format option, then always return that. Otherwise, return the default format, unless --pipe was specified, in which case return the default pipe format, format-pipe.

n.b. --pipe is a handy option introduced in Drush 2 (or perhaps even Drush 1) that indicates that the command should select the output format that is most appropriate for use in scripts (e.g. to pipe to another command).

Parameters

FormatterOptions $options

Return Value

string

protected chooseOutputStream(OutputInterface $output, $status)

Determine whether we should use stdout or stderr.

Parameters

OutputInterface $output
$status

protected writeUsingFormatter(OutputInterface $output, $structuredOutput, CommandData $commandData, $status = 0)

Call the formatter to output the provided data.

Parameters

OutputInterface $output
$structuredOutput
CommandData $commandData
$status

protected type writeErrorMessage(OutputInterface $output, int $status, string $structuredOutput, mixed $originalResult)

Description

Parameters

OutputInterface $output
int $status
string $structuredOutput
mixed $originalResult

Return Value

type

protected writeCommandOutput(OutputInterface $output, $structuredOutput, $status = 0)

If the result object is a string, then print it.

Parameters

OutputInterface $output
$structuredOutput
$status

protected interpretStatusCode($status)

If a status code was set, then return it; otherwise, presume success.

Parameters

$status