forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.php
More file actions
76 lines (72 loc) · 2.74 KB
/
Task.php
File metadata and controls
76 lines (72 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace ProcessMaker\Http\Resources;
use ProcessMaker\Http\Resources\ApiCollection;
use ProcessMaker\Http\Resources\Users;
use ProcessMaker\Models\User;
use StdClass;
class Task extends ApiResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$array = parent::toArray($request);
$include = explode(',', $request->input('include', ''));
if (in_array('data', $include)) {
$array['data'] = $this->processRequest->data;
}
if (in_array('user', $include)) {
$array['user'] = new Users($this->user);
}
if (in_array('requestor', $include)) {
$array['requestor'] = new Users($this->processRequest->user);
}
if (in_array('processRequest', $include)) {
$array['process_request'] = new Users($this->processRequest);
}
if (in_array('component', $include)) {
$array['component'] = $this->getScreen() ? $this->getScreen()->renderComponent() : null;
}
if (in_array('screen', $include)) {
$array['screen'] = $this->getScreen() ? $this->getScreen()->toArray() : null;
}
if (in_array('requestData', $include)) {
$array['request_data'] = $this->processRequest->data ?: new StdClass();
}
if (in_array('definition', $include)) {
$array['definition'] = $this->getDefinition();
}
if (in_array('bpmnTagName', $include)) {
$array['bpmn_tag_name'] = $this->getBpmnDefinition()->localName;
}
if (in_array('interstitial', $include)) {
$interstitial = $this->getInterstitial();
$array['allow_interstitial'] = $interstitial['allow_interstitial'];
$array['interstitial_screen'] = $interstitial['interstitial_screen'];
}
if (in_array('assignableUsers', $include)) {
$definition = $this->getDefinition();
$assignment = isset($definition['assignment']) ? $definition['assignment'] : 'requester';
switch ($assignment) {
case 'self_service':
case 'cyclical':
case 'group':
$ids = $this->process->getAssignableUsers($this->element_id);
$users = User::where('status', 'ACTIVE')->whereIn('id', $ids)->get();
break;
case 'user':
case 'requester':
$users = User::where('status', 'ACTIVE')->get();
break;
default:
$users = [];
}
$array['assignable_users'] = $users;
}
return $array;
}
}