1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
ConditionFactory.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Notification\Group\Condition
;
4
5
use
Bitrix\Im\Model\EO_NotifyGroupCondition_Collection
;
6
use
Bitrix\Im\Model\NotifyGroupConditionTable
;
7
use
Bitrix\Im\V2\Notification\Group\SystemGroup\SystemGroup
;
8
9
class
ConditionFactory
10
{
11
public
function
makeByTag
(
string
$tag,
int
$userId
):
Conditions
12
{
13
return
match ($tag)
14
{
15
SystemGroup::Confirm->value => $this->makeOnlyConfirms(),
16
SystemGroup::Mention->value => $this->makeMention(),
17
SystemGroup::Admin
->value => $this->makeAdmin(),
18
default
=> $this->makeUserTag($tag,
$userId
),
19
};
20
}
21
22
private
function
makeOnlyConfirms():
Conditions
23
{
24
return
(
new
Conditions
())
25
->
setOnlyConfirms
(
true
)
26
;
27
}
28
29
private
function
makeMention():
Conditions
30
{
31
return
(
new
Conditions
())
32
->
appendModuleEvent
(
new
ModuleEventCondition(
''
,
'mention'
))
33
->appendModuleEvent(
new
ModuleEventCondition(
''
,
'mention_comment'
))
34
;
35
}
36
37
private
function
makeAdmin():
Conditions
38
{
39
return
(
new
Conditions
())
40
->
appendModuleEvent
(
new
ModuleEventCondition(
'blog'
,
'log_notify_all_request'
))
41
->appendModuleEvent(
new
ModuleEventCondition(
'imbot'
,
'refresh_error'
))
42
->appendModuleEvent(
new
ModuleEventCondition(
'intranet'
,
'refresh_error'
))
43
->appendModuleEvent(
new
ModuleEventCondition(
'voximplant'
,
'notifications'
))
44
->appendModuleEvent(
new
ModuleEventCondition(
'voximplant'
,
'status_notifications'
))
45
->appendModuleEvent(
new
ModuleEventCondition(
''
,
'admin_notification'
))
46
;
47
}
48
49
private
function
makeUserTag(
string
$tag,
int
$userId
):
Conditions
50
{
51
if
(!is_numeric($tag) ||
$userId
<= 0)
52
{
53
return
new
Conditions
();
54
}
55
56
$id = (int)$tag;
57
58
$collection = $this->getModelCollection($id,
$userId
);
59
60
return
$this->
convertCollectionToConditionsDto
($collection);
61
}
62
63
private
function
getModelCollection(
int
$id,
int
$userId
): EO_NotifyGroupCondition_Collection
64
{
65
return
NotifyGroupConditionTable::query
()
66
->where(
NotifyGroupConditionTable::FIELD_GROUP_ID
, $id)
67
->where(
NotifyGroupConditionTable::FIELD_USER_ID
,
$userId
)
68
->setSelect([
69
NotifyGroupConditionTable::FIELD_ID
,
70
NotifyGroupConditionTable::FIELD_MODULE
,
71
NotifyGroupConditionTable::FIELD_EVENT
,
72
])
73
->fetchCollection()
74
;
75
}
76
77
public
function
convertCollectionToConditionsDto
(
EO_NotifyGroupCondition_Collection
$collection):
Conditions
78
{
79
$conditions =
new
Conditions
();
80
foreach
($collection as $model)
81
{
82
$item =
new
ModuleEventCondition
($model->getModule(), $model->getEvent());
83
$conditions->appendModuleEvent($item);
84
}
85
86
return
$conditions;
87
}
88
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Im\Model\EO_NotifyGroupCondition_Collection
Определения
orm.php:2276
Bitrix\Im\Model\NotifyGroupConditionTable
Определения
notifygroupconditiontable.php:30
Bitrix\Im\Model\NotifyGroupConditionTable\FIELD_USER_ID
const FIELD_USER_ID
Определения
notifygroupconditiontable.php:37
Bitrix\Im\Model\NotifyGroupConditionTable\FIELD_MODULE
const FIELD_MODULE
Определения
notifygroupconditiontable.php:35
Bitrix\Im\Model\NotifyGroupConditionTable\FIELD_GROUP_ID
const FIELD_GROUP_ID
Определения
notifygroupconditiontable.php:34
Bitrix\Im\Model\NotifyGroupConditionTable\FIELD_ID
const FIELD_ID
Определения
notifygroupconditiontable.php:33
Bitrix\Im\Model\NotifyGroupConditionTable\FIELD_EVENT
const FIELD_EVENT
Определения
notifygroupconditiontable.php:36
Bitrix\Im\V2\Notification\Group\Condition\ConditionFactory
Определения
ConditionFactory.php:10
Bitrix\Im\V2\Notification\Group\Condition\ConditionFactory\convertCollectionToConditionsDto
convertCollectionToConditionsDto(EO_NotifyGroupCondition_Collection $collection)
Определения
ConditionFactory.php:77
Bitrix\Im\V2\Notification\Group\Condition\ConditionFactory\makeByTag
makeByTag(string $tag, int $userId)
Определения
ConditionFactory.php:11
Bitrix\Im\V2\Notification\Group\Condition\Conditions
Определения
Conditions.php:6
Bitrix\Im\V2\Notification\Group\Condition\Conditions\appendModuleEvent
appendModuleEvent(ModuleEventCondition $moduleEventCondition)
Определения
Conditions.php:46
Bitrix\Im\V2\Notification\Group\Condition\Conditions\setOnlyConfirms
setOnlyConfirms(bool $value)
Определения
Conditions.php:16
Bitrix\Im\V2\Notification\Group\Condition\ModuleEventCondition
Определения
ModuleEventCondition.php:6
Bitrix\Main\ORM\Data\DataManager\query
static query()
Определения
datamanager.php:549
Bitrix\Im\V2\Notification\Group\Condition
Определения
ConditionFactory.php:3
Bitrix\Im\V2\Notification\Group\SystemGroup\SystemGroup
SystemGroup
Определения
SystemGroup.php:6
Bitrix\Im\V2\Notification\Group\SystemGroup\Admin
@ Admin
Определения
SystemGroup.php:9
bitrix
modules
im
lib
V2
Notification
Group
Condition
ConditionFactory.php
Создано системой
1.14.0