14 $operationParameters = [];
16 if (isset($documentType[3]))
18 $operationParameters[
'DocumentCategoryId'] = $documentType[3];
21 $documentType = \CBPHelper::ParseDocumentId($documentType);
22 $type = Bizproc\FieldType::normalizeProperty($type);
24 $user = $this->getCurrentUser();
28 && !\CBPDocument::CanUserOperateDocumentType(
29 \CBPCanUserOperateOperation::ViewWorkflow,
45 private function renderControlOptionsAction(array $documentType, array $type, array $params)
53 ->validateRequire(
'Func')
54 ->validateEnum(
'Func', [
55 'BPRIASwitchSubTypeControl',
56 'BWFVCSwitchSubTypeControl',
57 'WFSSwitchSubTypeControlC',
58 'WFSSwitchSubTypeControlV',
59 'WFSSwitchSubTypeControlP',
61 ->setDefault(
'Value',
'')
64 $runtime = \CBPRuntime::GetRuntime();
65 $runtime->StartRuntime();
66 $documentService = $runtime->GetService(
"DocumentService");
68 return $documentService->GetFieldInputControlOptions(
78 if (!$this->request->isJson())
82 new Error(
'', 0, [
'reason' =>
'Wrong request format. Expected json in request body.'])
88 $documentType = $this->request->getJsonList()->get(
'documentType');
89 $controlsData = $this->request->getJsonList()->get(
'controlsData');
91 $createInternalError =
static fn ($reason) =>
new Error(
'', 0, [
'reason' => $reason]);
93 if (!is_array($documentType))
96 $createInternalError(
'Wrong request format. Expected documentType in request json body.')
99 if (!is_array($controlsData))
102 $createInternalError(
'Wrong request format. Expected controlsData in request json body.')
107 foreach ($controlsData as $data)
110 is_array($data[
'property'] ??
null)
111 && is_array($data[
'params'] ??
null)
115 $property = $this->normalizeProperty($data[
'property']);
118 ->validateRequire(
'Field')
120 ->setPureValue(
'Value')
121 ->setDefault(
'Value',
'')
122 ->validateRequire(
'Als')
123 ->validateNumeric(
'Als')
124 ->validateEnum(
'RenderMode', [
'public',
'designer',
''])
125 ->setDefault(
'RenderMode',
'')
129 $renderer->addProperty($documentType, $property, $params);
133 return new HtmlContent($renderer, additionalResponseParams: $renderer->getRenderedProperties());
144 ->validateRequire(
'Field')
146 ->setPureValue(
'Value')
147 ->setDefault(
'Value',
'')
148 ->validateRequire(
'Als')
149 ->validateNumeric(
'Als')
150 ->validateEnum(
'RenderMode', [
'public',
'designer',
''])
151 ->setDefault(
'RenderMode',
'')
154 $property = $this->normalizeProperty($property);
156 return new HtmlContent(
new Response\RenderControlContent($documentType, $property, $params));
159 private function normalizeProperty(array $property): array
162 isset($property[
'OptionsSort']) && is_array($property[
'OptionsSort'])
163 && isset($property[
'Options'])
164 && is_array($property[
'Options'])
165 && count($property[
'OptionsSort']) === count($property[
'Options'])
170 foreach ($property[
'OptionsSort'] as $optionKey)
172 if (!isset($property[
'Options'][$optionKey]))
174 $sortSuccess =
false;
177 $sortedOptions[$optionKey] = $property[
'Options'][$optionKey];
181 $property[
'Options'] = $sortedOptions;
static getMessage($code, $replace=null, $language=null)