Mercurial > hg > isophonics-drupal-site
comparison vendor/consolidation/annotated-command/src/Hooks/Dispatchers/CommandEventHookDispatcher.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Consolidation\AnnotatedCommand\Hooks\Dispatchers; | |
4 | |
5 use Consolidation\AnnotatedCommand\Hooks\HookManager; | |
6 use Symfony\Component\Console\Command\Command; | |
7 use Symfony\Component\Console\ConsoleEvents; | |
8 use Symfony\Component\Console\Event\ConsoleCommandEvent; | |
9 use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
10 use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |
11 | |
12 /** | |
13 * Call hooks | |
14 */ | |
15 class CommandEventHookDispatcher extends HookDispatcher | |
16 { | |
17 /** | |
18 * @param ConsoleCommandEvent $event | |
19 */ | |
20 public function callCommandEventHooks(ConsoleCommandEvent $event) | |
21 { | |
22 $hooks = [ | |
23 HookManager::PRE_COMMAND_EVENT, | |
24 HookManager::COMMAND_EVENT, | |
25 HookManager::POST_COMMAND_EVENT | |
26 ]; | |
27 $commandEventHooks = $this->getHooks($hooks); | |
28 foreach ($commandEventHooks as $commandEvent) { | |
29 if ($commandEvent instanceof EventDispatcherInterface) { | |
30 $commandEvent->dispatch(ConsoleEvents::COMMAND, $event); | |
31 } | |
32 if (is_callable($commandEvent)) { | |
33 $commandEvent($event); | |
34 } | |
35 } | |
36 } | |
37 } |