1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
base.php
См. документацию.
1<?php
2
4
10
11abstract class Base extends \CBitrixComponent implements Errorable
12{
15
16 public function __construct($component = null)
17 {
18 parent::__construct($component);
19
20 $this->errorCollection = new ErrorCollection();
21 }
22
23 public function getErrors(): array
24 {
25 return $this->errorCollection->toArray();
26 }
27
28 public function getErrorByCode($code): ?Error
29 {
30 return $this->errorCollection->getErrorByCode($code);
31 }
32
33 public static function getTemplateViewData(array $template, $documentType)
34 {
35 foreach ($template['ROBOTS'] as $i => $robot)
36 {
37 $template['ROBOTS'][$i]['viewData'] = static::getRobotViewData($robot, $documentType);
38 }
39
40 return $template;
41 }
42
43 public static function getRobotViewData($robot, array $documentType): array
44 {
46 $result = [
47 'responsibleLabel' => '',
48 'responsibleUrl' => '',
49 'responsibleId' => 0,
50 'isInvalid' => false,
51 ];
52
53 $type = mb_strtolower($robot['Type'] ?? '');
54 if (isset($availableRobots[$type]['ROBOT_SETTINGS']))
55 {
56 $settings = $availableRobots[$type]['ROBOT_SETTINGS'];
57
58 if (!empty($settings['RESPONSIBLE_TO_HEAD']) && $robot['Properties'][$settings['RESPONSIBLE_TO_HEAD']] === 'Y')
59 {
60 $result['responsibleLabel'] = Loc::getMessage('BIZPROC_AUTOMATION_COMPONENT_BASE_TO_HEAD');
61 }
62
63 if (isset($settings['RESPONSIBLE_PROPERTY']))
64 {
65 $users = static::getUsersFromResponsibleProperty($robot, $settings['RESPONSIBLE_PROPERTY']);
66 $usersLabel = \CBPHelper::UsersArrayToString($users, [], $documentType, false);
67
68 if ($result['responsibleLabel'] && $usersLabel)
69 {
70 $result['responsibleLabel'] .= ', ';
71 }
72 $result['responsibleLabel'] .= $usersLabel;
73
74 if ($users && count($users) === 1 && $users[0] && mb_strpos($users[0], 'user_') === 0)
75 {
76 $id = (int) \CBPHelper::StripUserPrefix($users[0]);
77 $result['responsibleUrl'] = \CComponentEngine::MakePathFromTemplate(
78 '/company/personal/user/#user_id#/',
79 array('user_id' => $id)
80 );
81 $result['responsibleId'] = $id;
82 }
83 }
84 }
85 elseif (!isset($availableRobots[$type]))
86 {
87 $result['isInvalid'] = true;
88 }
89
90 return $result;
91 }
92
93 public static function getRunningCustomRobots(array $documentId, $template): array
94 {
95 if (!empty($template) && $template?->getId() > 0)
96 {
97 return \Bitrix\Bizproc\Workflow\Entity\WorkflowInstanceTable::getList([
98 'select' => ['ID'],
99 'filter' => [
100 '=MODULE_ID' => $documentId[0],
101 '=ENTITY' => $documentId[1],
102 '=DOCUMENT_ID' => $documentId[2],
103 '=WORKFLOW_TEMPLATE_ID' => $template->getId(),
104 '!STARTED_EVENT_TYPE' => \CBPDocumentEventType::Debug,
105 '=TEMPLATE.TYPE' => WorkflowTemplateType::CustomRobots->value,
106 ]
107 ])->fetchAll();
108 }
109
110 return [];
111 }
112
113 protected static function getUsersFromResponsibleProperty(array $robot, $propertyName): ?array
114 {
115 $value = null;
116 $props = $robot['Properties'];
117 $path = explode('.', $propertyName);
118
119 foreach ($path as $chain)
120 {
121 $value = ($props && is_array($props) && isset($props[$chain])) ? $props[$chain] : null;
122 $props = $value;
123 }
124
125 return $value ? (array)$value : null;
126 }
127}
$path
Определения access_edit.php:21
$type
Определения options.php:106
__construct($component=null)
Определения base.php:16
static getTemplateViewData(array $template, $documentType)
Определения base.php:33
static getRunningCustomRobots(array $documentId, $template)
Определения base.php:93
static getUsersFromResponsibleProperty(array $robot, $propertyName)
Определения base.php:113
static getRobotViewData($robot, array $documentType)
Определения base.php:43
getErrorByCode($code)
Определения base.php:28
static getAvailableRobots(array $documentType)
Определения template.php:350
Определения error.php:15
const Debug
Определения constants.php:159
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$props
Определения template.php:269