Skip to content

Commit a9870ad

Browse files
committed
add shouldCancel and shouldRun
1 parent 2ea2bb1 commit a9870ad

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Models/Workflow.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,18 @@ public function run(
257257
if (
258258
$this->isFinished() ||
259259
$this->isFailed() ||
260-
$this->isCanceled()
260+
$this->isCanceled() ||
261+
! $this->definition->shouldRun()
261262
) {
262263
return;
263264
}
264265

266+
if ($this->definition->shouldCancel()) {
267+
$this->markAsCanceled();
268+
269+
return;
270+
}
271+
265272
$readySteps = $this->definition
266273
->steps($this)
267274
->filter(function ($step, $name) {

src/WorkflowDefinition.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ public function start(): Workflow
2727

2828
return $workflow;
2929
}
30+
31+
public function shouldCancel(): bool
32+
{
33+
return false;
34+
}
35+
36+
public function shouldRun(): bool
37+
{
38+
return true;
39+
}
3040
}

0 commit comments

Comments
 (0)