Mercurial > hg > isophonics-drupal-site
view vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InteractHookDispatcher.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Consolidation\AnnotatedCommand\Hooks\Dispatchers; use Consolidation\AnnotatedCommand\AnnotationData; use Consolidation\AnnotatedCommand\Hooks\HookManager; use Consolidation\AnnotatedCommand\Hooks\InteractorInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** * Call hooks */ class InteractHookDispatcher extends HookDispatcher { public function interact( InputInterface $input, OutputInterface $output, AnnotationData $annotationData ) { $hooks = [ HookManager::PRE_INTERACT, HookManager::INTERACT, HookManager::POST_INTERACT ]; $interactors = $this->getHooks($hooks, $annotationData); foreach ($interactors as $interactor) { $this->callInteractor($interactor, $input, $output, $annotationData); } } protected function callInteractor($interactor, $input, $output, AnnotationData $annotationData) { if ($interactor instanceof InteractorInterface) { return $interactor->interact($input, $output, $annotationData); } if (is_callable($interactor)) { return $interactor($input, $output, $annotationData); } } }