1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
AttachArray.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Message\Param;
4
5
use Bitrix\Im\Text;
6
use Bitrix\Main\ArgumentException;
7
use Bitrix\Im\V2\Message\Param;
8
use Bitrix\Im\V2\Message\ParamArray;
9
use Bitrix\Im\V2\Result;
10
11
class
AttachArray
extends
ParamArray
12
{
17
public
function
setValue
($values): self
18
{
19
if
(!is_array($values) || \
Bitrix
\
Main
\
Type
\Collection::isAssociative($values))
20
{
21
$values = [$values];
22
}
23
24
foreach
($this as $param)
25
{
26
$param->markDrop();
27
}
28
29
foreach
($values as $value)
30
{
31
if
(!$value instanceof \CIMMessageParamAttach)
32
{
33
$value = \CIMMessageParamAttach::GetAttachByJson($value);
34
}
35
36
$this->
addValue
($value);
37
}
38
39
$this->
markChanged
();
40
41
return
$this;
42
}
43
44
49
public
function
addValue
($value): self
50
{
51
if
(!$value instanceof \CIMMessageParamAttach)
52
{
53
$value = \CIMMessageParamAttach::GetAttachByJson($value);
54
}
55
56
$param =
new
Attach
();
57
$param
58
->setName($this->
getName
())
59
->setType(
Param::TYPE_JSON
)
60
->setValue($value)
61
;
62
63
if
(!$param->hasValue())
64
{
65
return
$this;
66
}
67
68
if
($this->
getMessageId
())
69
{
70
$param->setMessageId($this->
getMessageId
());
71
}
72
73
if
($param->getPrimaryId())
74
{
75
$param->setRegistry($this);
76
}
77
else
78
{
79
$this[] = $param;
80
}
81
82
$this->
markChanged
();
83
84
return
$this;
85
}
86
90
public
function
getValue
():
array
91
{
92
$values = [];
93
foreach
($this as $param)
94
{
95
if
($param->isDeleted())
96
{
97
continue
;
98
}
99
$values[] = $param->getValue();
100
}
101
102
return
$values;
103
}
104
108
public
function
toRestFormat
(): ?
array
109
{
110
return
$this->
getValue
();
111
}
112
113
117
public
function
toPullFormat
():
array
118
{
119
$values = [];
120
foreach
($this as $param)
121
{
122
if
($param->isDeleted() || !$param->hasValue())
123
{
124
continue
;
125
}
126
$values[] = \CIMMessageParamAttach::PrepareAttach($param->getValue());
127
}
128
129
return
$values;
130
}
131
132
public
function
isValid
():
Result
133
{
134
$result
=
new
Result
();
135
137
foreach
($this as $attach)
138
{
139
$checkAttachResult = $attach->isValid();
140
if
(!$checkAttachResult->isSuccess())
141
{
142
$result
->addErrors($checkAttachResult->getErrors());
143
}
144
}
145
146
return
$result
;
147
}
148
}
Bitrix\Im\V2\Message\Param\AttachArray
Определения
AttachArray.php:12
Bitrix\Im\V2\Message\Param\AttachArray\toPullFormat
toPullFormat()
Определения
AttachArray.php:117
Bitrix\Im\V2\Message\Param\AttachArray\setValue
setValue($values)
Определения
AttachArray.php:17
Bitrix\Im\V2\Message\Param\AttachArray\addValue
addValue($value)
Определения
AttachArray.php:49
Bitrix\Im\V2\Message\Param\AttachArray\getValue
getValue()
Определения
AttachArray.php:90
Bitrix\Im\V2\Message\Param\AttachArray\toRestFormat
toRestFormat()
Определения
AttachArray.php:108
Bitrix\Im\V2\Message\ParamArray
Определения
ParamArray.php:22
Bitrix\Im\V2\Message\ParamArray\getName
getName()
Определения
ParamArray.php:337
Bitrix\Im\V2\Message\ParamArray\getMessageId
getMessageId()
Определения
ParamArray.php:312
Bitrix\Im\V2\Message\ParamArray\isValid
isValid()
Определения
ParamArray.php:370
Bitrix\Im\V2\Message\ParamArray\markChanged
markChanged(?bool $state=null)
Определения
ParamArray.php:394
Bitrix\Main\DB\Result
Определения
result.php:20
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Im\V2\Chat\Param\TYPE_JSON
const TYPE_JSON
Определения
Param.php:20
Bitrix\Im\V2\Message\Attach
Определения
AttachService.php:3
Bitrix\Main\Type
Определения
collection.php:2
Bitrix\Main
Bitrix
bitrix
modules
im
lib
V2
Message
Param
AttachArray.php
Создано системой
1.14.0