Mercurial > hg > isophonics-drupal-site
comparison vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.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 Consolidation\AnnotatedCommand\AnnotationData; | |
7 use Consolidation\AnnotatedCommand\Hooks\InitializeHookInterface; | |
8 use Symfony\Component\Console\Command\Command; | |
9 use Symfony\Component\Console\Input\InputInterface; | |
10 | |
11 /** | |
12 * Call hooks | |
13 */ | |
14 class InitializeHookDispatcher extends HookDispatcher implements InitializeHookInterface | |
15 { | |
16 public function initialize( | |
17 InputInterface $input, | |
18 AnnotationData $annotationData | |
19 ) { | |
20 $hooks = [ | |
21 HookManager::PRE_INITIALIZE, | |
22 HookManager::INITIALIZE, | |
23 HookManager::POST_INITIALIZE | |
24 ]; | |
25 $providers = $this->getHooks($hooks, $annotationData); | |
26 foreach ($providers as $provider) { | |
27 $this->callInitializeHook($provider, $input, $annotationData); | |
28 } | |
29 } | |
30 | |
31 protected function callInitializeHook($provider, $input, AnnotationData $annotationData) | |
32 { | |
33 if ($provider instanceof InitializeHookInterface) { | |
34 return $provider->initialize($input, $annotationData); | |
35 } | |
36 if (is_callable($provider)) { | |
37 return $provider($input, $annotationData); | |
38 } | |
39 } | |
40 } |