10 private array $additionalSelectFields = [];
11 private array $sort = [];
12 private array $filter = [];
13 private int $offset = 0;
14 private int $limit = 10;
16 private function __construct(
17 private int $targetUserId,
26 $targetUserId = self::validateUserId($request->filter[
'USER_ID'] ?? 0);
32 $tasksToGet =
new self($targetUserId);
34 if ($request->additionalSelectFields)
36 $tasksToGet->setAdditionalSelectFields($request->additionalSelectFields);
40 $tasksToGet->setSort($request->sort);
43 $tasksToGet->offset = $request->offset;
44 $tasksToGet->limit = $request->limit;
45 $tasksToGet->filter = $request->filter;
54 private static function validateUserId(
int $userId): int
56 return max($userId, 0);
64 return $this->targetUserId;
71 private function setAdditionalSelectFields(array $additionalSelectFields): void
73 $additionalAllowedFields = [
78 'WORKFLOW_TEMPLATE_ID',
82 'WORKFLOW_TEMPLATE_NAME',
83 'WORKFLOW_TEMPLATE_TEMPLATE_ID',
85 'WORKFLOW_STARTED_BY',
89 foreach ($additionalSelectFields as $fieldId)
91 if (in_array($fieldId, $additionalAllowedFields,
true))
97 $this->additionalSelectFields = $fields;
105 return $this->additionalSelectFields;
112 private function setSort(array $sort): void
130 return $this->filter;
138 return $this->offset;
156 'WORKFLOW_ID' =>
'WORKFLOW_ID',
157 'ACTIVITY' =>
'ACTIVITY',
158 'MODIFIED' =>
'MODIFIED',
159 'OVERDUE_DATE' =>
'OVERDUE_DATE',
160 'PARAMETERS' =>
'PARAMETERS',
161 'IS_INLINE' =>
'IS_INLINE',
162 'STATUS' =>
'STATUS',
163 'DOCUMENT_NAME' =>
'DOCUMENT_NAME',
164 'USER_ID' =>
'USER_ID',
165 'USER_STATUS' =>
'USER_STATUS',
166 'WORKFLOW_STATE' =>
'WORKFLOW_STATE',
171 $selectFields[$fieldId] = $fieldId;
174 return array_keys($selectFields);