1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
EntityChat.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Chat;
4
5
use Bitrix\Im\Model\ChatTable;
6
use Bitrix\Im\Model\RelationTable;
7
use Bitrix\Im\V2\Chat;
8
use Bitrix\Im\V2\Result;
9
use Bitrix\Im\V2\Service\Context;
10
use Bitrix\Main\Localization\Loc;
11
12
class
EntityChat
extends
GroupChat
13
{
14
protected
const
ENTITY_SEPARATOR
=
'|'
;
15
16
protected
const
ENTITY_MAP_FIELDS
= [
'entityId'
,
'entityData1'
,
'entityData2'
,
'entityData3'
];
17
18
protected
$entityMap
= [
19
'entityId'
=> [],
20
'entityData1'
=> [],
21
'entityData2'
=> [],
22
'entityData3'
=> [],
23
];
24
25
protected
$entityData
= [];
26
27
public
function
setEntityMap
(
array
$entityMap
): self
28
{
29
foreach
(
$entityMap
as $field =>
$map
)
30
{
31
if
(in_array($field, self::ENTITY_MAP_FIELDS,
true
) && is_array(
$map
))
32
{
33
$this->entityMap[$field] = array_values(
$map
);
34
}
35
}
36
37
return
$this;
38
}
39
40
public
function
getEntityMap
():
array
41
{
42
return
$this->entityMap
;
43
}
44
49
public
function
getEntityData
(
bool
$force =
false
):
array
50
{
51
if
(!
count
($this->entityData) || $force)
52
{
53
$this->entityData = $this->unmapEntity();
54
}
55
56
return
$this->entityData
;
57
}
58
59
private
function
unmapEntity():
array
60
{
61
$result
= [];
62
foreach
($this->
getEntityMap
() as $entityType => $entityFields)
63
{
64
if
(!
count
($entityFields))
65
{
66
continue
;
67
}
68
69
if
($this->$entityType)
70
{
71
$data
= explode(self::ENTITY_SEPARATOR, $this->$entityType);
72
if
(
count
($entityFields) ===
count
(
$data
))
73
{
74
$result
[$entityType] = array_combine($entityFields,
$data
);
75
}
76
else
77
{
78
$result
[$entityType] =
$data
;
79
}
80
}
81
else
82
{
83
$result
[$entityType] = array_fill_keys($entityFields,
null
);
84
}
85
}
86
return
$result
;
87
}
88
99
public
static
function
find
(
array
$params
= [], ?
Context
$context
=
null
):
Result
100
{
101
$result
=
new
Result
;
102
103
if
(empty(
$params
[
'ENTITY_TYPE'
]) || empty(
$params
[
'ENTITY_ID'
]))
104
{
105
return
$result
->addError(
new
ChatError
(
ChatError::WRONG_PARAMETER
));
106
}
107
108
$row = ChatTable::query()
109
->setSelect([
'ID'
,
'TYPE'
,
'ENTITY_TYPE'
,
'ENTITY_ID'
])
110
->where(
'ENTITY_TYPE'
,
$params
[
'ENTITY_TYPE'
])
111
->where(
'ENTITY_ID'
,
$params
[
'ENTITY_ID'
])
112
->
fetch
()
113
;
114
115
if
($row)
116
{
117
$result
->setResult([
118
'ID'
=> (
int
)$row[
'ID'
],
119
'TYPE'
=> $row[
'TYPE'
],
120
'ENTITY_TYPE'
=> $row[
'ENTITY_TYPE'
],
121
'ENTITY_ID'
=> $row[
'ENTITY_ID'
],
122
]);
123
}
124
125
return
$result
;
126
}
127
}
Bitrix\Im\V2\Chat\ChatError
Определения
ChatError.php:9
Bitrix\Im\V2\Chat\ChatError\WRONG_PARAMETER
const WRONG_PARAMETER
Определения
ChatError.php:12
Bitrix\Im\V2\Chat\EntityChat
Определения
EntityChat.php:13
Bitrix\Im\V2\Chat\EntityChat\$entityData
$entityData
Определения
EntityChat.php:25
Bitrix\Im\V2\Chat\EntityChat\getEntityMap
getEntityMap()
Определения
EntityChat.php:40
Bitrix\Im\V2\Chat\EntityChat\find
static find(array $params=[], ?Context $context=null)
Определения
EntityChat.php:99
Bitrix\Im\V2\Chat\EntityChat\setEntityMap
setEntityMap(array $entityMap)
Определения
EntityChat.php:27
Bitrix\Im\V2\Chat\EntityChat\ENTITY_MAP_FIELDS
const ENTITY_MAP_FIELDS
Определения
EntityChat.php:16
Bitrix\Im\V2\Chat\EntityChat\$entityMap
$entityMap
Определения
EntityChat.php:18
Bitrix\Im\V2\Chat\EntityChat\ENTITY_SEPARATOR
const ENTITY_SEPARATOR
Определения
EntityChat.php:14
Bitrix\Im\V2\Chat\EntityChat\getEntityData
getEntityData(bool $force=false)
Определения
EntityChat.php:49
Bitrix\Im\V2\Chat\GroupChat
Определения
GroupChat.php:40
Bitrix\Main\DB\Result
Определения
result.php:20
Bitrix\Main\DB\Result\fetch
fetch(\Bitrix\Main\Text\Converter $converter=null)
Определения
result.php:179
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
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
$context
$context
Определения
csv_new_setup.php:223
$map
$map
Определения
config.php:5
Bitrix\Main\Context
Определения
culture.php:9
count
</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
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
im
lib
V2
Chat
EntityChat.php
Создано системой
1.14.0