Ejemplo n.º 1
0
 /**
  * Run every task in a list, but only up to the first failure.
  * Return the failing result, or success if all tasks run.
  *
  * @param string $name
  * @param TaskInterface[] $taskList
  * @param \Robo\Result $result
  *
  * @return \Robo\Result
  *
  * @throws \Robo\Exception\TaskExitException
  */
 private function runTaskList($name, array $taskList, Result $result)
 {
     try {
         foreach ($taskList as $taskName => $task) {
             $taskResult = $this->runSubtask($task);
             $this->advanceProgressIndicator();
             // If the current task returns an error code, then stop
             // execution and signal a rollback.
             if (!$taskResult->wasSuccessful()) {
                 return $taskResult;
             }
             // We accumulate our results into a field so that tasks that
             // have a reference to the collection may examine and modify
             // the incremental results, if they wish.
             $key = Result::isUnnamed($taskName) ? $name : $taskName;
             $result->accumulate($key, $taskResult);
         }
     } catch (TaskExitException $exitException) {
         $this->fail();
         throw $exitException;
     } catch (\Exception $e) {
         // Tasks typically should not throw, but if one does, we will
         // convert it into an error and roll back.
         return Result::fromException($task, $e, $result->getData());
     }
     return $result;
 }