當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GrumPHP::stopOnFailure方法代碼示例

本文整理匯總了PHP中GrumPHP\Configuration\GrumPHP::stopOnFailure方法的典型用法代碼示例。如果您正苦於以下問題:PHP GrumPHP::stopOnFailure方法的具體用法?PHP GrumPHP::stopOnFailure怎麽用?PHP GrumPHP::stopOnFailure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GrumPHP\Configuration\GrumPHP的用法示例。


在下文中一共展示了GrumPHP::stopOnFailure方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * @param ContextInterface $context
  *
  * @throws FailureException if any of the tasks fail
  */
 public function run(ContextInterface $context)
 {
     $failures = false;
     $messages = array();
     $tasks = $this->tasks->filterByContext($context)->sortByPriority($this->grumPHP);
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, new RunnerEvent($tasks));
     foreach ($tasks as $task) {
         try {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_RUN, new TaskEvent($task));
             $task->run($context);
             $this->eventDispatcher->dispatch(TaskEvents::TASK_COMPLETE, new TaskEvent($task));
         } catch (RuntimeException $e) {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_FAILED, new TaskFailedEvent($task, $e));
             $messages[] = $e->getMessage();
             $failures = true;
             if ($this->grumPHP->stopOnFailure()) {
                 break;
             }
         }
     }
     if ($failures) {
         $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, new RunnerFailedEvent($tasks, $messages));
         throw new FailureException(implode(PHP_EOL, $messages));
     }
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, new RunnerEvent($tasks));
 }
開發者ID:eltonoliveira,項目名稱:grumphp,代碼行數:31,代碼來源:TaskRunner.php

示例2: run

 /**
  * @param ContextInterface $context
  *
  * @return TaskResultCollection
  */
 public function run(ContextInterface $context)
 {
     $tasks = $this->tasks->filterByContext($context)->sortByPriority($this->grumPHP);
     $taskResults = new TaskResultCollection();
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, new RunnerEvent($tasks, $context, $taskResults));
     foreach ($tasks as $task) {
         try {
             $taskResult = $this->runTask($task, $context);
         } catch (RuntimeException $e) {
             $taskResult = TaskResult::createFailed($task, $context, $e->getMessage());
         }
         $taskResults->add($taskResult);
         if (!$taskResult->isPassed() && $taskResult->isBlocking() && $this->grumPHP->stopOnFailure()) {
             break;
         }
     }
     if ($taskResults->isFailed()) {
         $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, new RunnerFailedEvent($tasks, $context, $taskResults));
         return $taskResults;
     }
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, new RunnerEvent($tasks, $context, $taskResults));
     return $taskResults;
 }
開發者ID:Big-Shark,項目名稱:grumphp,代碼行數:28,代碼來源:TaskRunner.php

示例3:

 function it_does_not_stop_on_a_non_blocking_failed_task_if_stop_on_failure(GrumPHP $grumPHP, TaskInterface $task1, TaskInterface $task2, ContextInterface $context)
 {
     $grumPHP->stopOnFailure()->willReturn(true);
     $grumPHP->isBlockingTask('task1')->willReturn(false);
     $task1->run($context)->willReturn(TaskResult::createFailed($task1->getWrappedObject(), $context->getWrappedObject(), ''));
     $task2->run($context)->shouldBeCalled();
     $this->run($context)->shouldHaveCount(2);
 }
開發者ID:Big-Shark,項目名稱:grumphp,代碼行數:8,代碼來源:TaskRunnerSpec.php


注:本文中的GrumPHP\Configuration\GrumPHP::stopOnFailure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。