Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
templatescope.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Automation\Engine
;
4
5
use Bitrix\Bizproc\WorkflowTemplateTable;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Result
;
9
10
class
TemplateScope
11
{
13
private
$complexDocumentType;
15
private
$documentCategoryId;
17
private
$documentStatus;
18
20
private
$categoryName;
22
private
$statusName;
24
private
$statusColor;
25
26
public
function
__construct
(array $documentType, $categoryId,
string
$status)
27
{
28
$this->complexDocumentType = $documentType;
29
$this->documentCategoryId = $categoryId;
30
$this->documentStatus = $status;
31
}
32
33
public
function
getTemplate
(): ?
Template
34
{
35
try
36
{
37
$template =
new
Template
($this->complexDocumentType, $this->documentStatus);
38
}
39
catch
(\Exception $exception)
40
{
41
$template =
null
;
42
}
43
44
return
$template;
45
}
46
47
public
function
setNames
(?
string
$categoryName, ?
string
$statusName): self
48
{
49
$this->categoryName = $categoryName;
50
$this->statusName = $statusName;
51
52
return
$this;
53
}
54
55
public
function
setStatusColor
(
string
$color): self
56
{
57
$this->statusColor = $color;
58
59
return
$this;
60
}
61
62
public
function
getId
(): string
63
{
64
return
"{$this->getModuleId()}_{$this->getDocumentType()}_{$this->getCategoryId()}_{$this->getStatusId()}"
;
65
}
66
67
public
function
getModuleId
(): string
68
{
69
return
$this->
getComplexDocumentType
()[0];
70
}
71
72
public
function
getEntity
(): string
73
{
74
return
$this->
getComplexDocumentType
()[1];
75
}
76
77
public
function
getDocumentType
(): string
78
{
79
return
$this->
getComplexDocumentType
()[2];
80
}
81
82
public
function
getComplexDocumentType
(): array
83
{
84
return
$this->complexDocumentType;
85
}
86
87
public
function
getCategoryId
()
88
{
89
return
$this->documentCategoryId;
90
}
91
92
public
function
getStatusId
(): string
93
{
94
return
$this->documentStatus;
95
}
96
97
public
function
toArray
(): array
98
{
99
$documentService = \CBPRuntime::GetRuntime(
true
)->getDocumentService();
100
101
return
[
102
'DocumentType'
=> [
103
'Type'
=> $this->
getComplexDocumentType
(),
104
'Name'
=> $documentService->getDocumentTypeName($this->complexDocumentType),
105
],
106
'Category'
=> [
107
'Id'
=> $this->
getCategoryId
(),
108
'Name'
=> $this->categoryName,
109
],
110
'Status'
=> [
111
'Id'
=> $this->
getStatusId
(),
112
'Name'
=> $this->statusName,
113
'Color'
=> $this->statusColor,
114
],
115
];
116
}
117
118
public
static
function
fromArray
(array $rawScope): ?
TemplateScope
119
{
120
if
(
121
is_array($rawScope[
'DocumentType'
] ??
null
)
122
&& is_array($rawScope[
'Category'
] ??
null
)
123
&& is_array($rawScope[
'Status'
] ??
null
)
124
)
125
{
126
$scope =
new
static
(
127
$rawScope[
'DocumentType'
][
'Type'
] ?? [],
128
$rawScope[
'Category'
][
'Id'
] ??
null
,
129
$rawScope[
'Status'
][
'Id'
] ??
''
,
130
);
131
$scope->
setNames
(
132
$rawScope[
'Category'
][
'Name'
] ??
null
,
133
$rawScope[
'Status'
][
'Name'
] ??
null
134
);
135
136
if
(isset($rawScope[
'Status'
][
'Color'
]) && is_string($rawScope[
'Status'
][
'Color'
]))
137
{
138
$scope->setStatusColor($rawScope[
'Status'
][
'Color'
]);
139
}
140
141
return
$scope;
142
}
143
144
return
null
;
145
}
146
}
Bitrix\Bizproc\Automation\Engine\Template
Definition
template.php:22
Bitrix\Bizproc\Automation\Engine\TemplateScope
Definition
templatescope.php:11
Bitrix\Bizproc\Automation\Engine\TemplateScope\getEntity
getEntity()
Definition
templatescope.php:72
Bitrix\Bizproc\Automation\Engine\TemplateScope\setNames
setNames(?string $categoryName, ?string $statusName)
Definition
templatescope.php:47
Bitrix\Bizproc\Automation\Engine\TemplateScope\getId
getId()
Definition
templatescope.php:62
Bitrix\Bizproc\Automation\Engine\TemplateScope\setStatusColor
setStatusColor(string $color)
Definition
templatescope.php:55
Bitrix\Bizproc\Automation\Engine\TemplateScope\getStatusId
getStatusId()
Definition
templatescope.php:92
Bitrix\Bizproc\Automation\Engine\TemplateScope\getTemplate
getTemplate()
Definition
templatescope.php:33
Bitrix\Bizproc\Automation\Engine\TemplateScope\toArray
toArray()
Definition
templatescope.php:97
Bitrix\Bizproc\Automation\Engine\TemplateScope\fromArray
static fromArray(array $rawScope)
Definition
templatescope.php:118
Bitrix\Bizproc\Automation\Engine\TemplateScope\getComplexDocumentType
getComplexDocumentType()
Definition
templatescope.php:82
Bitrix\Bizproc\Automation\Engine\TemplateScope\getModuleId
getModuleId()
Definition
templatescope.php:67
Bitrix\Bizproc\Automation\Engine\TemplateScope\getDocumentType
getDocumentType()
Definition
templatescope.php:77
Bitrix\Bizproc\Automation\Engine\TemplateScope\__construct
__construct(array $documentType, $categoryId, string $status)
Definition
templatescope.php:26
Bitrix\Bizproc\Automation\Engine\TemplateScope\getCategoryId
getCategoryId()
Definition
templatescope.php:87
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Bizproc\Automation\Engine
Definition
condition.php:2
modules
bizproc
lib
automation
engine
templatescope.php
Создано системой
1.10.0