1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ConditionFactory.php
См. документацию.
1<?php
2
4
8
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 {
68 ->setSelect([
72 ])
73 ->fetchCollection()
74 ;
75 }
76
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}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
convertCollectionToConditionsDto(EO_NotifyGroupCondition_Collection $collection)
Определения ConditionFactory.php:77
appendModuleEvent(ModuleEventCondition $moduleEventCondition)
Определения Conditions.php:46