forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompleteActivity.php
More file actions
61 lines (52 loc) · 1.74 KB
/
CompleteActivity.php
File metadata and controls
61 lines (52 loc) · 1.74 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace ProcessMaker\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use ProcessMaker\Facades\Metrics;
use ProcessMaker\Managers\DataManager;
use ProcessMaker\Models\Process as Definitions;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
class CompleteActivity extends BpmnAction implements ShouldQueue
{
public $definitionsId;
public $instanceId;
public $tokenId;
public $data;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Definitions $definitions, ExecutionInstanceInterface $instance, TokenInterface $token, array $data)
{
$this->definitionsId = $definitions->getKey();
$this->instanceId = $instance->getKey();
$this->tokenId = $token->getKey();
$this->data = $data;
}
/**
* Execute the job.
*
* @return void
*/
public function action(ProcessRequestToken $token, ActivityInterface $element, array $data)
{
//@todo requires a class to manage the data access and control the updates
$manager = new DataManager();
$manager->updateData($token, $data);
$this->engine->runToNextState();
$element->complete($token);
Metrics::counterInc(
'activity_completed_total',
'Total number of activities completed',
[
'activity_id' => $element->getId(),
'activity_name' => $element->getName(),
'process_id' => $this->definitionsId,
'request_id' => $this->instanceId,
]
);
}
}