blob: ea799ce1412777f25e118a0160052f9f7923d3df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
namespace Temporal\Tests\Workflow;
use Temporal\Activity\ActivityOptions;
use Temporal\Tests\Activity\SimpleActivity;
use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;
#[Workflow\WorkflowInterface]
class CancelledMidflightWorkflow
{
private array $status = [];
#[Workflow\QueryMethod(name: 'getStatus')]
public function getStatus(): array
{
return $this->status;
}
#[WorkflowMethod(name: 'CancelledMidflightWorkflow')]
public function handler()
{
$simple = Workflow::newActivityStub(
SimpleActivity::class,
ActivityOptions::new()->withStartToCloseTimeout(5)
);
$this->status[] = 'start';
$scope = Workflow::newCancellationScope(
function () use ($simple) {
$this->status[] = 'in scope';
$simple->slow('1');
}
)->onCancel(
function () {
$this->status[] = 'on cancel';
}
);
$scope->cancel();
$this->status[] = 'done cancel';
return 'OK';
}
}
|