HookManager
class HookManager implements EventSubscriberInterface (View source)
Manage named callback hooks
Constants
REPLACE_COMMAND_HOOK |
|
PRE_COMMAND_EVENT |
|
COMMAND_EVENT |
|
POST_COMMAND_EVENT |
|
PRE_OPTION_HOOK |
|
OPTION_HOOK |
|
POST_OPTION_HOOK |
|
PRE_INITIALIZE |
|
INITIALIZE |
|
POST_INITIALIZE |
|
PRE_INTERACT |
|
INTERACT |
|
POST_INTERACT |
|
PRE_ARGUMENT_VALIDATOR |
|
ARGUMENT_VALIDATOR |
|
POST_ARGUMENT_VALIDATOR |
|
PRE_COMMAND_HOOK |
|
COMMAND_HOOK |
|
POST_COMMAND_HOOK |
|
PRE_PROCESS_RESULT |
|
PROCESS_RESULT |
|
POST_PROCESS_RESULT |
|
PRE_ALTER_RESULT |
|
ALTER_RESULT |
|
POST_ALTER_RESULT |
|
STATUS_DETERMINER |
|
EXTRACT_OUTPUT |
|
ON_EVENT |
|
Properties
protected | $hooks | ||
protected | $hookOptions | var CommandInfo[] |
Methods
No description
No description
Add a hook
No description
No description
No description
If a command hook does not specify any particular command name that it should be attached to, then it will be applied to every command that is defined in the same class as the hook.
Add a replace command hook
No description
No description
No description
No description
Add an configuration provider hook
Add a pre-command hook. This is the same as a validator hook, except that it will run after all of the post-validator hooks.
Add a post-command hook. This is the same as a pre-process hook, except that it will run before the first pre-process hook.
Add a result processor.
Add a result alterer. After a result is processed by a result processor, an alter hook may be used to convert the result from one form to another.
Add a status determiner. Usually, a command should return an integer on error, or a result object on success (which implies a status code of zero). If a result contains the status code in some other field, then a status determiner can be used to call the appropriate accessor method to determine the status code. This is usually not necessary, though; a command that fails may return a CommandError object, which contains a status code and a result message to display.
Add an output extractor. If a command returns an object object, by default it is passed directly to the output formatter (if in use) for rendering. If the result object contains more information than just the data to render, though, then an output extractor can be used to call the appopriate accessor method of the result object to get the data to rendered. This is usually not necessary, though; it is preferable to have complex result objects implement the OutputDataInterface.
No description
No description
Get a set of hooks with the provided name(s). Include the pre- and post- hooks, and also include the global hooks ('*') in addition to the named hooks provided.
No description
Get a set of hooks with the provided name(s).
Get a single named hook.
Call the command event hooks.
No description
Details
__construct()
No description
getAllHooks()
No description
add(callable $callback, string $hook, string $name = '*')
Add a hook
recordHookOptions($commandInfo, $name)
No description
static
getNames($command, $callback)
No description
static protected
getNamesUsingCommands($command)
No description
static protected
getClassNameFromCallback($callback)
If a command hook does not specify any particular command name that it should be attached to, then it will be applied to every command that is defined in the same class as the hook.
This is controlled by using the namespace + class name of the implementing class of the callback hook.
addReplaceCommandHook(ReplaceCommandHookInterface $replaceCommandHook, $name)
Add a replace command hook
addPreCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
No description
addCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
No description
addPostCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
No description
addCommandEvent(EventSubscriberInterface $eventSubscriber)
No description
addInitializeHook(InitializeHookInterface $initializeHook, type $name = '*')
Add an configuration provider hook
addOptionHook(OptionHookInterface $interactor, type $name = '*')
Add an option hook
addInteractor(InteractorInterface $interactor, type $name = '*')
Add an interact hook
addPreValidator(ValidatorInterface $validator, type $name = '*')
Add a pre-validator hook
addValidator(ValidatorInterface $validator, type $name = '*')
Add a validator hook
addPreCommandHook(ValidatorInterface $preCommand, type $name = '*')
Add a pre-command hook. This is the same as a validator hook, except that it will run after all of the post-validator hooks.
addPostCommandHook(ProcessResultInterface $postCommand, type $name = '*')
Add a post-command hook. This is the same as a pre-process hook, except that it will run before the first pre-process hook.
addResultProcessor(ProcessResultInterface $resultProcessor, type $name = '*')
Add a result processor.
addAlterResult(AlterResultInterface $resultAlterer, type $name = '*')
Add a result alterer. After a result is processed by a result processor, an alter hook may be used to convert the result from one form to another.
addStatusDeterminer(StatusDeterminerInterface $statusDeterminer, type $name = '*')
Add a status determiner. Usually, a command should return an integer on error, or a result object on success (which implies a status code of zero). If a result contains the status code in some other field, then a status determiner can be used to call the appropriate accessor method to determine the status code. This is usually not necessary, though; a command that fails may return a CommandError object, which contains a status code and a result message to display.
addOutputExtractor(ExtractOutputInterface $outputExtractor, type $name = '*')
Add an output extractor. If a command returns an object object, by default it is passed directly to the output formatter (if in use) for rendering. If the result object contains more information than just the data to render, though, then an output extractor can be used to call the appopriate accessor method of the result object to get the data to rendered. This is usually not necessary, though; it is preferable to have complex result objects implement the OutputDataInterface.
getHookOptionsForCommand($command)
No description
CommandInfo[]
getHookOptions($names)
No description
callable[]
getHooks(string|array $names, string[] $hooks, $annotationData = null)
Get a set of hooks with the provided name(s). Include the pre- and post- hooks, and also include the global hooks ('*') in addition to the named hooks provided.
protected
addWildcardHooksToNames($names, $annotationData = null)
No description
callable[]
get(string|array $names, string[] $hooks)
Get a set of hooks with the provided name(s).
callable[]
getHook(string $name, string $hook)
Get a single named hook.
callCommandEventHooks(ConsoleCommandEvent $event)
Call the command event hooks.
TODO: This should be moved to CommandEventHookDispatcher, which should become the class that implements EventSubscriberInterface. This change would break all clients, though, so postpone until next major release.
static
getSubscribedEvents()
No description