1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
WebResultHandler.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Result;
4
5use Bitrix\Main\Localization\Loc;
6use Bitrix\Bizproc\Workflow\Entity\WorkflowStateTable;
7
9{
10 protected string $workflowId;
11
12 public function __construct(string $workflowId)
13 {
14 $this->workflowId = $workflowId;
15 }
16
17 public function handle(RenderedResult $renderedResult = null): array
18 {
19 static $cache = [];
20
21 $noResult = [
22 'text' => Loc::getMessage('BIZPROC_WEB_RESULT_WORKFLOW_NO_RESULT'),
24 ];
25
26 if (is_null($renderedResult))
27 {
28 if (isset($cache[$this->workflowId]))
29 {
30 return $cache[$this->workflowId];
31 }
32
33 $state = WorkflowStateTable::getByPrimary(
34 $this->workflowId,
35 ['select' => ['STARTED_BY', 'MODULE_ID', 'ENTITY', 'DOCUMENT_ID']]
36 )->fetchObject();
37 if (!$state)
38 {
39 $cache[$this->workflowId] = $noResult;
40
41 return $cache[$this->workflowId];
42 }
43
44 $startedBy = $state->getStartedBy();
45 if (empty($startedBy))
46 {
47 $startedBy = \CCrmBizProcHelper::getDocumentResponsibleId($state->getComplexDocumentId());
48 }
49
51
52 if ($userName)
53 {
55 $userLink = '[URL=/company/personal/user/' . $startedBy . '/]' . $userName . '[/URL]';
56 $text = Loc::getMessage('BIZPROC_WEB_RESULT_WORKFLOW_RESULT_USER', ['#USER#' => $userLink]) ?? '';
57
58 $cache[$this->workflowId] = [
59 'text' => \CBPHelper::convertBBtoText($text),
61 ];
62
63 return $cache[$this->workflowId];
64 }
65
66 $cache[$this->workflowId] = $noResult;
67
68 return $cache[$this->workflowId];
69 }
70
71 switch ($renderedResult->status)
72 {
74 return [
76 \CBPHelper::convertBBtoText(
77 preg_replace('|\n+|', "\n", trim($renderedResult->text ?? '')),
78 )),
79 'status' => $renderedResult->status,
80 ];
81
83 return [
84 'text' => \CBPHelper::convertBBtoText(
85 Loc::getMessage(
86 'BIZPROC_WEB_RESULT_WORKFLOW_RESULT_USER',
87 ['#USER#' => $renderedResult->text]
88 ) ?? '',
89 ),
90 'status' => $renderedResult->status,
91 ];
92
94 return [
95 'text' => $renderedResult->text ?? '',
96 'status' => $renderedResult->status,
97 ];
99 return $noResult;
100 }
101 }
102}
handle(RenderedResult $renderedResult=null)
Определения WebResultHandler.php:17
__construct(string $workflowId)
Определения WebResultHandler.php:12
static getUserFullNameById(int $userId)
Определения viewhelper.php:161
static prepareTaskDescription($description)
Определения viewhelper.php:254
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
$text
Определения template_pdf.php:79
else $userName
Определения order_form.php:75