2 namespace Robo\Collection;
4 use Consolidation\AnnotatedCommand\Hooks\ProcessResultInterface;
5 use Consolidation\AnnotatedCommand\CommandData;
6 use Robo\Contract\TaskInterface;
10 * The collection process hook is added to the annotation command
11 * hook manager in Runner::configureContainer(). This hook will be
12 * called every time a command runs. If the command result is a
13 * \Robo\Contract\TaskInterface (in particular, \Robo\Collection\Collection),
14 * then we run the collection, and return the result. We ignore results
17 class CollectionProcessHook implements ProcessResultInterface
20 * @param \Robo\Result|\Robo\Contract\TaskInterface $result
21 * @param \Consolidation\AnnotatedCommand\CommandData $commandData
23 * @return null|\Robo\Result
25 public function process($result, CommandData $commandData)
27 if ($result instanceof TaskInterface) {
29 return $result->run();
30 } catch (\Exception $e) {
31 return Result::fromException($result, $e);