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