forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreviousTaskAssignee.php
More file actions
39 lines (35 loc) · 1.22 KB
/
Copy pathPreviousTaskAssignee.php
File metadata and controls
39 lines (35 loc) · 1.22 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
<?php
namespace ProcessMaker\AssignmentRules;
use ProcessMaker\Contracts\AssignmentRuleInterface;
use ProcessMaker\Exception\ThereIsNoPreviousUserAssignedException;
use ProcessMaker\Models\Process;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
/**
* Before a task is assigned, search the tokens table for a previously assigned
* task and use that users id for the new assignment.
*/
class PreviousTaskAssignee implements AssignmentRuleInterface
{
/**
* Before a task is assigned, search the tokens table for a previously
* assigned task and use that users id for the new assignment.
*
* @param ActivityInterface $task
* @param TokenInterface $token
* @param Process $process
* @param ProcessRequest $request
* @return type
*/
public function getNextUser(ActivityInterface $task, TokenInterface $token, Process $process, ProcessRequest $request)
{
$previous = $request->tokens()
->where('element_type', 'task')
->orderBy('id', 'desc')->first();
if (!$previous) {
return null;
}
return $previous->user_id;
}
}