diff --git a/src/Models/Workflow.php b/src/Models/Workflow.php index a68e182..921baf2 100644 --- a/src/Models/Workflow.php +++ b/src/Models/Workflow.php @@ -257,11 +257,18 @@ public function run( if ( $this->isFinished() || $this->isFailed() || - $this->isCanceled() + $this->isCanceled() || + ! $this->definition->shouldRun() ) { return; } + if ($this->definition->shouldCancel()) { + $this->markAsCanceled(); + + return; + } + $readySteps = $this->definition ->steps($this) ->filter(function ($step, $name) { diff --git a/src/WorkflowDefinition.php b/src/WorkflowDefinition.php index 9235262..42ccf4d 100644 --- a/src/WorkflowDefinition.php +++ b/src/WorkflowDefinition.php @@ -27,4 +27,14 @@ public function start(): Workflow return $workflow; } + + public function shouldCancel(): bool + { + return false; + } + + public function shouldRun(): bool + { + return true; + } }