1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
ActivityStorage.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Bizproc\Storage
;
4
5
use
Bitrix\Main\Web\Json
;
6
7
class
ActivityStorage
8
{
9
private
static
$instances = [];
10
11
private
$tplId;
12
private
$name;
13
private
$values;
14
15
public
static
function
getInstance
(
int
$tplId,
string
$name): self
16
{
17
$cacheKey = $tplId .
'|'
. $name;
18
19
if
(!isset(self::$instances[$cacheKey]))
20
{
21
self::$instances[$cacheKey] =
new
self
($tplId, $name);
22
}
23
24
return
self::$instances[$cacheKey];
25
}
26
27
private
function
__construct(
int
$tplId,
string
$name
)
28
{
29
$this->tplId = $tplId;
30
$this->name =
$name
;
31
}
32
33
private
function
__clone()
34
{
35
}
36
37
public
function
getValue
(
string
$key
)
38
{
39
$row = $this->
getAll
()[$key] ??
null
;
40
41
return
$row ? $row[
'value'
] :
null
;
42
}
43
44
public
function
setValue
(
string
$key
, $value): self
45
{
46
$row = $this->
getAll
()[$key] ??
null
;
47
48
if
($row)
49
{
50
if
($value ===
null
)
51
{
52
Entity\ActivityStorageTable::delete
($row[
'id'
]);
53
unset($this->values[
$key
]);
54
}
55
else
56
{
57
$this->values[
$key
][
'value'
] = $value;
58
Entity\ActivityStorageTable::update
($row[
'id'
], [
'KEY_VALUE'
=> Json::encode($value)]);
59
}
60
}
61
else
62
{
63
$this->
addValue
($key, $value);
64
}
65
66
return
$this;
67
}
68
69
protected
function
getAll
()
70
{
71
if
($this->values ===
null
)
72
{
73
$this->values = [];
74
$listResult =
Entity\ActivityStorageTable::getList
([
75
'filter'
=> [
76
'=WORKFLOW_TEMPLATE_ID'
=> $this->tplId,
77
'=ACTIVITY_NAME'
=> $this->name
78
]
79
]);
80
81
foreach
($listResult as $item)
82
{
83
$this->values[$item[
'KEY_ID'
]] = [
84
'id'
=> $item[
'ID'
],
85
'value'
=> Json::decode($item[
'KEY_VALUE'
])
86
];
87
}
88
}
89
90
return
$this->values;
91
}
92
93
protected
function
addValue
(
string
$key
, $value)
94
{
95
$result
=
Entity\ActivityStorageTable::add
([
96
'WORKFLOW_TEMPLATE_ID'
=> $this->tplId,
97
'ACTIVITY_NAME'
=> $this->name,
98
'KEY_ID'
=>
$key
,
99
'KEY_VALUE'
=> Json::encode($value)
100
]);
101
102
$id =
$result
->getId();
103
104
if
(is_array($this->values))
105
{
106
$this->values[
$key
] = [
107
'id'
=> $id,
108
'value'
=> $value
109
];
110
}
111
112
return
$id;
113
}
114
115
public
static
function
onAfterTemplateDelete
(
int
$id)
116
{
117
$listResult =
Entity\ActivityStorageTable::getList
([
118
'filter'
=> [
119
'=WORKFLOW_TEMPLATE_ID'
=> $id,
120
],
121
'select'
=> [
'ID'
]
122
]);
123
124
foreach
($listResult as $item)
125
{
126
Entity\ActivityStorageTable::delete
($item[
'ID'
]);
127
}
128
}
129
}
Bitrix\Bizproc\Storage\ActivityStorage
Определения
ActivityStorage.php:8
Bitrix\Bizproc\Storage\ActivityStorage\addValue
addValue(string $key, $value)
Определения
ActivityStorage.php:93
Bitrix\Bizproc\Storage\ActivityStorage\setValue
setValue(string $key, $value)
Определения
ActivityStorage.php:44
Bitrix\Bizproc\Storage\ActivityStorage\getValue
getValue(string $key)
Определения
ActivityStorage.php:37
Bitrix\Bizproc\Storage\ActivityStorage\getAll
getAll()
Определения
ActivityStorage.php:69
Bitrix\Bizproc\Storage\ActivityStorage\getInstance
static getInstance(int $tplId, string $name)
Определения
ActivityStorage.php:15
Bitrix\Bizproc\Storage\ActivityStorage\onAfterTemplateDelete
static onAfterTemplateDelete(int $id)
Определения
ActivityStorage.php:115
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\ORM\Data\DataManager\delete
static delete($primary)
Определения
datamanager.php:1644
Bitrix\Main\ORM\Data\DataManager\add
static add(array $data)
Определения
datamanager.php:877
Bitrix\Main\ORM\Data\DataManager\update
static update($primary, array $data)
Определения
datamanager.php:1256
Bitrix\Main\Web\Json
Определения
json.php:9
$result
$result
Определения
get_property_values.php:14
$name
$name
Определения
menu_edit.php:35
Bitrix\Bizproc\Storage
Определения
ActivityStorage.php:3
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
bitrix
modules
bizproc
lib
Storage
ActivityStorage.php
Создано системой
1.14.0