Mercurial > hg > isophonics-drupal-site
annotate 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 |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Consolidation\AnnotatedCommand\Hooks\Dispatchers; |
Chris@0 | 4 |
Chris@0 | 5 use Consolidation\AnnotatedCommand\Hooks\HookManager; |
Chris@0 | 6 use Symfony\Component\Console\Command\Command; |
Chris@0 | 7 use Symfony\Component\Console\ConsoleEvents; |
Chris@0 | 8 use Symfony\Component\Console\Event\ConsoleCommandEvent; |
Chris@0 | 9 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
Chris@0 | 10 use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
Chris@0 | 11 |
Chris@0 | 12 /** |
Chris@0 | 13 * Call hooks |
Chris@0 | 14 */ |
Chris@0 | 15 class CommandEventHookDispatcher extends HookDispatcher |
Chris@0 | 16 { |
Chris@0 | 17 /** |
Chris@0 | 18 * @param ConsoleCommandEvent $event |
Chris@0 | 19 */ |
Chris@0 | 20 public function callCommandEventHooks(ConsoleCommandEvent $event) |
Chris@0 | 21 { |
Chris@0 | 22 $hooks = [ |
Chris@0 | 23 HookManager::PRE_COMMAND_EVENT, |
Chris@0 | 24 HookManager::COMMAND_EVENT, |
Chris@0 | 25 HookManager::POST_COMMAND_EVENT |
Chris@0 | 26 ]; |
Chris@0 | 27 $commandEventHooks = $this->getHooks($hooks); |
Chris@0 | 28 foreach ($commandEventHooks as $commandEvent) { |
Chris@0 | 29 if ($commandEvent instanceof EventDispatcherInterface) { |
Chris@0 | 30 $commandEvent->dispatch(ConsoleEvents::COMMAND, $event); |
Chris@0 | 31 } |
Chris@0 | 32 if (is_callable($commandEvent)) { |
Chris@0 | 33 $commandEvent($event); |
Chris@0 | 34 } |
Chris@0 | 35 } |
Chris@0 | 36 } |
Chris@0 | 37 } |