30 userId: $request->userId,
31 complexDocumentId: $request->complexDocumentId,
33 \CBPDocument::PARAM_TAGRET_USER =>
'user_' . $request->targetUserId,
34 'DocumentCategoryId' => $request->documentCategoryId,
37 $accessResponse = $this->accessService->checkStartWorkflow($accessRequest);
38 if (!$accessResponse->isSuccess())
40 $response->addErrors($accessResponse->getErrors());
44 if (isset($request->startDuration) && $request->startDuration < 0)
49 $startWorkflowErrors = [];
50 $instanceId = \CBPDocument::startWorkflow(
52 $request->complexDocumentId,
55 $request->parentWorkflow,
58 if ($startWorkflowErrors)
60 foreach ($startWorkflowErrors as $error)
62 if (is_numeric($error[
'code']))
64 $response->addError(
new Error($error[
'message'], (
int)$error[
'code']));
68 $response->addError(
new Error($error[
'message']));
72 elseif (is_null($instanceId))
80 if (isset($request->startDuration))
82 $metadata =
new EO_WorkflowMetadata();
84 $metadata->setWorkflowId($instanceId);
85 $metadata->setStartDuration($request->startDuration);
89 $response->setWorkflowId($instanceId);