ResultWriter
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
Return the formatter manager
No description
Handle the result output and status code calculation.
No description
Determine whether we should use stdout or stderr.
Call the formatter to output the provided data.
Description
If the result object is a string, then print it.
If a status code was set, then return it; otherwise, presume success.
Details
setFormatterManager(FormatterManager $formatterManager)
No description
FormatterManager
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.
protected
dataCanBeFormatted($structuredOutput)
No description
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).
protected
chooseOutputStream(OutputInterface $output, $status)
Determine whether we should use stdout or stderr.
protected
writeUsingFormatter(OutputInterface $output, $structuredOutput, CommandData $commandData, $status = 0)
Call the formatter to output the provided data.
protected type
writeErrorMessage(OutputInterface $output, int $status, string $structuredOutput, mixed $originalResult)
Description
protected
writeCommandOutput(OutputInterface $output, $structuredOutput, $status = 0)
If the result object is a string, then print it.
protected
interpretStatusCode($status)
If a status code was set, then return it; otherwise, presume success.