Add "core" automation integration & implement wait action
The "core" integration will provide triggers, actions, and subjects that are not specific to any 3rd party integration. [MAILPOET-4136]
This commit is contained in:
@@ -82,6 +82,12 @@ class StepRunner {
|
||||
throw Exceptions::workflowNotFound($workflowRun->getWorkflowId());
|
||||
}
|
||||
|
||||
// complete workflow run
|
||||
if (!$stepId) {
|
||||
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
|
||||
return;
|
||||
}
|
||||
|
||||
$step = $workflow->getStep($stepId);
|
||||
if (!$step) {
|
||||
throw Exceptions::workflowStepNotFound($stepId);
|
||||
@@ -94,19 +100,21 @@ class StepRunner {
|
||||
throw new InvalidStateException();
|
||||
}
|
||||
|
||||
// enqueue next step / complete workflow
|
||||
$nextStepId = $step->getNextStepId();
|
||||
if ($nextStepId) {
|
||||
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, [
|
||||
[
|
||||
'workflow_run_id' => $workflowRunId,
|
||||
'step_id' => $nextStepId,
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
|
||||
$nextStepArgs = [
|
||||
[
|
||||
'workflow_run_id' => $workflowRunId,
|
||||
'step_id' => $step->getNextStepId(),
|
||||
],
|
||||
];
|
||||
|
||||
// next step scheduled by action
|
||||
if ($this->actionScheduler->hasScheduledAction(Hooks::WORKFLOW_STEP, $nextStepArgs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// enqueue next step
|
||||
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, $nextStepArgs);
|
||||
|
||||
// TODO: allow long-running steps (that are not done here yet)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user