3 namespace Consolidation\AnnotatedCommand\Hooks\Dispatchers;
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;
14 class InteractHookDispatcher extends HookDispatcher
16 public function interact(
17 InputInterface $input,
18 OutputInterface $output,
19 AnnotationData $annotationData
22 HookManager::PRE_INTERACT,
23 HookManager::INTERACT,
24 HookManager::POST_INTERACT
26 $interactors = $this->getHooks($hooks, $annotationData);
27 foreach ($interactors as $interactor) {
28 $this->callInteractor($interactor, $input, $output, $annotationData);
32 protected function callInteractor($interactor, $input, $output, AnnotationData $annotationData)
34 if ($interactor instanceof InteractorInterface) {
35 return $interactor->interact($input, $output, $annotationData);
37 if (is_callable($interactor)) {
38 return $interactor($input, $output, $annotationData);