Mercurial > hg > isophonics-drupal-site
annotate vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InteractHookDispatcher.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\AnnotationData; |
Chris@0 | 6 use Consolidation\AnnotatedCommand\Hooks\HookManager; |
Chris@0 | 7 use Consolidation\AnnotatedCommand\Hooks\InteractorInterface; |
Chris@0 | 8 use Symfony\Component\Console\Input\InputInterface; |
Chris@0 | 9 use Symfony\Component\Console\Output\OutputInterface; |
Chris@0 | 10 |
Chris@0 | 11 /** |
Chris@0 | 12 * Call hooks |
Chris@0 | 13 */ |
Chris@0 | 14 class InteractHookDispatcher extends HookDispatcher |
Chris@0 | 15 { |
Chris@0 | 16 public function interact( |
Chris@0 | 17 InputInterface $input, |
Chris@0 | 18 OutputInterface $output, |
Chris@0 | 19 AnnotationData $annotationData |
Chris@0 | 20 ) { |
Chris@0 | 21 $hooks = [ |
Chris@0 | 22 HookManager::PRE_INTERACT, |
Chris@0 | 23 HookManager::INTERACT, |
Chris@0 | 24 HookManager::POST_INTERACT |
Chris@0 | 25 ]; |
Chris@0 | 26 $interactors = $this->getHooks($hooks, $annotationData); |
Chris@0 | 27 foreach ($interactors as $interactor) { |
Chris@0 | 28 $this->callInteractor($interactor, $input, $output, $annotationData); |
Chris@0 | 29 } |
Chris@0 | 30 } |
Chris@0 | 31 |
Chris@0 | 32 protected function callInteractor($interactor, $input, $output, AnnotationData $annotationData) |
Chris@0 | 33 { |
Chris@0 | 34 if ($interactor instanceof InteractorInterface) { |
Chris@0 | 35 return $interactor->interact($input, $output, $annotationData); |
Chris@0 | 36 } |
Chris@0 | 37 if (is_callable($interactor)) { |
Chris@0 | 38 return $interactor($input, $output, $annotationData); |
Chris@0 | 39 } |
Chris@0 | 40 } |
Chris@0 | 41 } |