コード例 #1
0
ファイル: SwfDecisionEngine.php プロジェクト: bravo3/workflow
 /**
  * Process a workflow decision, sending the reason back to the workflow engine
  *
  * @param Decision $decision
  */
 public function processDecision(Decision $decision)
 {
     switch ($decision->getWorkflowResult()) {
         // Complete a workflow
         case WorkflowResult::COMPLETE():
             $class = 'RespondDecisionCompleteCommand';
             $event = new CompletingWorkflowEvent($this->getWorkflow(), $decision->getExecutionId(), $decision->getResult());
             $this->dispatch(Event::DECISION_COMPLETE, $event);
             $this->getWorkflow()->onWorkflowSuccess($event);
             $this->getWorkflow()->onWorkflowComplete($event);
             break;
             // Fail a workflow
         // Fail a workflow
         case WorkflowResult::FAIL():
             $class = 'RespondDecisionFailedCommand';
             $event = new FailingWorkflowEvent($this->getWorkflow(), $decision->getExecutionId(), $decision->getReason());
             $this->dispatch(Event::DECISION_FAIL, $event);
             $this->getWorkflow()->onWorkflowFailed($event);
             $this->getWorkflow()->onWorkflowComplete($event);
             break;
             // Send workflow commands
         // Send workflow commands
         case WorkflowResult::COMMAND():
             $class = 'RespondDecisionScheduleCommand';
             foreach ($decision->getScheduledTasks() as $task) {
                 $this->dispatch(Event::DECISION_SCHEDULE, new SchedulingTaskEvent($task));
             }
             break;
             // Unsupported response
         // Unsupported response
         default:
             throw new UnexpectedValueException("Unknown workflow result: " . $decision->getWorkflowResult()->key());
     }
     $this->runCommand($class, ['decision' => $decision]);
 }
コード例 #2
0
ファイル: AlphaTask.php プロジェクト: bravo3/workflow
 /**
  * Code to be executed by the DECIDER when the task is complete
  *
  * This function allows your task to schedule additional tasks by manipulating the decision that follows the
  * success of this task.
  *
  * @param WorkflowInterface   $workflow
  * @param WorkflowHistoryItem $history_item
  * @param Decision            $decision
  * @return void
  */
 public function onSuccess(WorkflowInterface $workflow, WorkflowHistoryItem $history_item, Decision $decision)
 {
     if ($this->getAuxPayload() !== 'payload') {
         throw new \Exception("Payload incorrect (" . $this->getAuxPayload() . ")");
     }
     $schema = $this->getTask($workflow, 'bravo');
     $schema->setInput('lalala');
     $decision->scheduledTask($schema);
 }