Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
channeltable.php
1
<?php
2
namespace
Bitrix\MessageService\Internal\Entity
;
3
4
use
Bitrix\Main\Type\DateTime
;
5
use
Bitrix\Main\ORM\Data\DataManager
;
6
use
Bitrix\Main\ORM\Fields\StringField
;
7
use
Bitrix\Main\ORM\Fields\TextField
;
8
use
Bitrix\Main\ORM\Fields\ArrayField
;
9
use
Bitrix\Main\ORM\Fields\DatetimeField
;
10
use
Bitrix\Main\ORM\Fields\IntegerField
;
11
use
Bitrix\Main\ORM\Fields\Validators\LengthValidator
;
12
use Bitrix\Main\ORM\Data\Internal\DeleteByFilterTrait;
13
use Bitrix\Main\ORM\Data\Internal\MergeTrait;
14
use
Bitrix\Main\ORM\Query\Result
;
15
use
Bitrix\Main\Web\Json
;
16
17
18
class
ChannelTable
extends
DataManager
19
{
20
use MergeTrait;
21
use DeleteByFilterTrait;
22
26
public
static
function
getTableName
(): string
27
{
28
return
'b_messageservice_channel'
;
29
}
30
34
public
static
function
getMap
(): array
35
{
36
return
[
37
'ID'
=>
38
(
new
IntegerField
(
'ID'
))
39
->configurePrimary()
40
->configureAutocomplete()
41
,
42
'SENDER_ID'
=>
43
(
new
StringField
(
'SENDER_ID'
))
44
->configureRequired()
45
->configureSize(50)
46
->addValidator(
new
LengthValidator
(1, 50))
47
,
48
'EXTERNAL_ID'
=>
49
(
new
StringField
(
'EXTERNAL_ID'
))
50
->configureRequired()
51
->configureSize(128)
52
->addValidator(
new
LengthValidator
(1, 128))
53
,
54
'TYPE'
=>
55
(
new
StringField
(
'TYPE'
))
56
->configureRequired()
57
->configureSize(30)
58
->addValidator(
new
LengthValidator
(1, 30))
59
,
60
'NAME'
=>
61
(
new
StringField
(
'NAME'
))
62
->configureRequired()
63
->configureSize(500)
64
->addValidator(
new
LengthValidator
(1, 500))
65
,
66
'ADDITIONAL_PARAMS'
=>
67
(
new
ArrayField
(
'ADDITIONAL_PARAMS'
))
68
->configureSerializationJson()
69
,
70
'DATE_CREATE'
=>
71
(
new
DatetimeField
(
'DATE_CREATE'
))
72
->configureDefaultValue(
function
()
73
{
74
return
new
DateTime
();
75
})
76
,
77
];
78
}
79
80
public
static
function
getChannelsByType
(
string
$senderId,
string
$type):
Result
81
{
82
return
self::getList
([
83
'filter'
=> [
84
'=SENDER_ID'
=> $senderId,
85
'=TYPE'
=> $type,
86
]
87
]);
88
}
89
90
public
static
function
reloadChannels
(
string
$senderId,
string
$type, array $channels): void
91
{
92
foreach
($channels as $channel)
93
{
94
if
(is_array($channel[
'ADDITIONAL_PARAMS'
]))
95
{
96
$channel[
'ADDITIONAL_PARAMS'
] = Json::encode($channel[
'ADDITIONAL_PARAMS'
]);
97
}
98
self::merge(
99
$channel,
100
[
101
'NAME'
=> $channel[
'NAME'
],
102
'ADDITIONAL_PARAMS'
=>$channel[
'ADDITIONAL_PARAMS'
],
103
],
104
[
'SENDER_ID'
,
'EXTERNAL_ID'
,
'TYPE'
]
105
);
106
}
107
self::deleteByFilter([
108
'=SENDER_ID'
=> $senderId,
109
'=TYPE'
=> $type,
110
'!=EXTERNAL_ID'
=> array_column($channels,
'EXTERNAL_ID'
)
111
]);
112
}
113
}
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\ORM\Fields\ArrayField
Definition
arrayfield.php:19
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\TextField
Definition
textfield.php:20
Bitrix\Main\ORM\Fields\Validators\LengthValidator
Definition
lengthvalidator.php:19
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Web\Json
Definition
json.php:11
Bitrix\MessageService\Internal\Entity\ChannelTable
Definition
channeltable.php:19
Bitrix\MessageService\Internal\Entity\ChannelTable\getChannelsByType
static getChannelsByType(string $senderId, string $type)
Definition
channeltable.php:80
Bitrix\MessageService\Internal\Entity\ChannelTable\getMap
static getMap()
Definition
channeltable.php:34
Bitrix\MessageService\Internal\Entity\ChannelTable\reloadChannels
static reloadChannels(string $senderId, string $type, array $channels)
Definition
channeltable.php:90
Bitrix\MessageService\Internal\Entity\ChannelTable\getTableName
static getTableName()
Definition
channeltable.php:26
Bitrix\MessageService\Internal\Entity
Definition
channeltable.php:2
modules
messageservice
lib
internal
entity
channeltable.php
Создано системой
1.10.0