class CommandProcessor implements LoggerAwareInterface (View source)

Process a command, including hooks and other callbacks.

There should only be one command processor per application. Provide your command processor to the AnnotatedCommandFactory via AnnotatedCommandFactory::setCommandProcessor().

Traits

LoggerAwareTrait

Properties

protected HookManager $hookManager
protected FormatterManager $formatterManager
protected PrepareFormatterOptions[] $prepareOptionsList
protected bool $passExceptions
protected ResultWriter $resultWriter
protected ParameterInjection $parameterInjection

Methods

__construct(HookManager $hookManager)

No description

hookManager()

Return the hook manager

resultWriter()

No description

setResultWriter($resultWriter)

No description

parameterInjection()

No description

setParameterInjection($parameterInjection)

No description

addPrepareFormatter(PrepareFormatter $preparer)

No description

setFormatterManager(FormatterManager $formatterManager)

No description

setDisplayErrorFunction(callable $fn)

No description

setPassExceptions($passExceptions)

Set a mode to make the annotated command library re-throw any exception that it catches while processing a command.

commandErrorForException(Exception $e)

No description

formatterManager()

Return the formatter manager

initializeHook(InputInterface $input, $names, AnnotationData $annotationData)

No description

optionsHook(AnnotatedCommand $command, $names, AnnotationData $annotationData)

No description

interact(InputInterface $input, OutputInterface $output, $names, AnnotationData $annotationData)

No description

process(OutputInterface $output, $names, $commandCallback, CommandData $commandData)

No description

validateRunAndAlter($names, $commandCallback, CommandData $commandData)

No description

processResults($names, $result, CommandData $commandData)

No description

updateFormatterOptions(CommandData $commandData)

Update the FormatterOptions object with validated command options.

handleResults(OutputInterface $output, $names, $result, CommandData $commandData)

Handle the result output and status code calculation.

runCommandCallback($commandCallback, CommandData $commandData)

Run the main command callback

injectIntoCommandData($commandData, $injectedClasses)

No description

Details

__construct(HookManager $hookManager)

No description

Parameters

HookManager $hookManager

HookManager hookManager()

Return the hook manager

Return Value

HookManager

resultWriter()

No description

setResultWriter($resultWriter)

No description

Parameters

$resultWriter

parameterInjection()

No description

setParameterInjection($parameterInjection)

No description

Parameters

$parameterInjection

addPrepareFormatter(PrepareFormatter $preparer)

No description

Parameters

PrepareFormatter $preparer

setFormatterManager(FormatterManager $formatterManager)

No description

Parameters

FormatterManager $formatterManager

setDisplayErrorFunction(callable $fn)

No description

Parameters

callable $fn

setPassExceptions($passExceptions)

Set a mode to make the annotated command library re-throw any exception that it catches while processing a command.

The default behavior in the current (2.x) branch is to catch the exception and replace it with a CommandError object that may be processed by the normal output processing passthrough.

In the 3.x branch, exceptions will never be caught; they will be passed through, as if setPassExceptions(true) were called. This is the recommended behavior.

Parameters

$passExceptions

commandErrorForException(Exception $e)

No description

Parameters

Exception $e

FormatterManager formatterManager()

Return the formatter manager

Return Value

FormatterManager

initializeHook(InputInterface $input, $names, AnnotationData $annotationData)

No description

Parameters

InputInterface $input
$names
AnnotationData $annotationData

optionsHook(AnnotatedCommand $command, $names, AnnotationData $annotationData)

No description

Parameters

AnnotatedCommand $command
$names
AnnotationData $annotationData

interact(InputInterface $input, OutputInterface $output, $names, AnnotationData $annotationData)

No description

Parameters

InputInterface $input
OutputInterface $output
$names
AnnotationData $annotationData

process(OutputInterface $output, $names, $commandCallback, CommandData $commandData)

No description

Parameters

OutputInterface $output
$names
$commandCallback
CommandData $commandData

validateRunAndAlter($names, $commandCallback, CommandData $commandData)

No description

Parameters

$names
$commandCallback
CommandData $commandData

processResults($names, $result, CommandData $commandData)

No description

Parameters

$names
$result
CommandData $commandData

protected FormatterOptions updateFormatterOptions(CommandData $commandData)

Update the FormatterOptions object with validated command options.

Also runs the perparers.

Parameters

CommandData $commandData

Return Value

FormatterOptions

handleResults(OutputInterface $output, $names, $result, CommandData $commandData)

Handle the result output and status code calculation.

Parameters

OutputInterface $output
$names
$result
CommandData $commandData

protected runCommandCallback($commandCallback, CommandData $commandData)

Run the main command callback

Parameters

$commandCallback
CommandData $commandData

injectIntoCommandData($commandData, $injectedClasses)

No description

Parameters

$commandData
$injectedClasses