1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Event.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Analytics\Event;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Main\Analytics\AnalyticsEvent;
7use Bitrix\Main\Engine\Response\Converter;
8
9abstract class Event
10{
12 protected Chat $chat;
13 protected ?string $type = null;
14 protected ?string $section = null;
15 protected ?string $subSection = null;
16 protected ?string $element = null;
17 protected ?string $status = null;
18 protected ?string $p1 = null;
19 protected ?string $p2 = null;
20 protected ?string $p3 = null;
21 protected ?string $p4 = null;
22 protected ?string $p5 = null;
23
24 public function __construct(string $eventName, Chat $chat, int $userId)
25 {
26 $this->chat = $chat;
27 $this->event = new AnalyticsEvent($eventName, $this->getTool(), $this->getCategory($eventName));
28 $this->event->setUserId($userId);
29 $this->setDefaultParams();
30 }
31
32 public function getEvent(): AnalyticsEvent
33 {
34 return $this->event;
35 }
36
37 abstract protected function getTool(): string;
38
39 abstract protected function getCategory(string $eventName): string;
40
41 protected function setDefaultParams(): self
42 {
43 return $this;
44 }
45
46 public static function convertUnderscore(string $string): string
47 {
48 return (new Converter(Converter::TO_CAMEL | Converter::LC_FIRST))->process($string);
49 }
50
51 public function send(): void
52 {
53 if ($this->type !== null)
54 {
55 $this->event->setType($this->type);
56 }
57 if ($this->section !== null)
58 {
59 $this->event->setSection($this->section);
60 }
61 if ($this->subSection !== null)
62 {
63 $this->event->setSubSection($this->subSection);
64 }
65 if ($this->element !== null)
66 {
67 $this->event->setElement($this->element);
68 }
69 if ($this->status !== null)
70 {
71 $this->event->setStatus($this->status);
72 }
73 if ($this->p1 !== null)
74 {
75 $this->event->setP1($this->p1);
76 }
77 if ($this->p2 !== null)
78 {
79 $this->event->setP2($this->p2);
80 }
81 if ($this->p3 !== null)
82 {
83 $this->event->setP3($this->p3);
84 }
85 if ($this->p4 !== null)
86 {
87 $this->event->setP4($this->p4);
88 }
89 if ($this->p5 !== null)
90 {
91 $this->event->setP5($this->p5);
92 }
93
94 $this->event->send();
95 }
96
97 public function setEvent(AnalyticsEvent $event): self
98 {
99 $this->event = $event;
100 return $this;
101 }
102
103 public function setChat(Chat $chat): self
104 {
105 $this->chat = $chat;
106 return $this;
107 }
108
109 public function setType(?string $type): self
110 {
111 $this->type = $type;
112 return $this;
113 }
114
115 public function setSection(?string $section): self
116 {
117 $this->section = $section;
118 return $this;
119 }
120
121 public function setSubSection(?string $subSection): self
122 {
123 $this->subSection = $subSection;
124 return $this;
125 }
126
127 public function setElement(?string $element): self
128 {
129 $this->element = $element;
130 return $this;
131 }
132
133 public function setStatus(?string $status): self
134 {
135 $this->status = $status;
136 return $this;
137 }
138
139 public function setP1(?string $p1): self
140 {
141 $this->p1 = $p1;
142 return $this;
143 }
144
145 public function setP2(?string $p2): self
146 {
147 $this->p2 = $p2;
148 return $this;
149 }
150
151 public function setP3(?string $p3): self
152 {
153 $this->p3 = $p3;
154 return $this;
155 }
156
157 public function setP4(?string $p4): self
158 {
159 $this->p4 = $p4;
160 return $this;
161 }
162
163 public function setP5(?string $p5): self
164 {
165 $this->p5 = $p5;
166 return $this;
167 }
168}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
setP5(?string $p5)
Определения Event.php:163
setSection(?string $section)
Определения Event.php:115
setType(?string $type)
Определения Event.php:109
setSubSection(?string $subSection)
Определения Event.php:121
setP3(?string $p3)
Определения Event.php:151
string $section
Определения Event.php:14
string $status
Определения Event.php:17
setEvent(AnalyticsEvent $event)
Определения Event.php:97
__construct(string $eventName, Chat $chat, int $userId)
Определения Event.php:24
setStatus(?string $status)
Определения Event.php:133
setChat(Chat $chat)
Определения Event.php:103
setElement(?string $element)
Определения Event.php:127
setP4(?string $p4)
Определения Event.php:157
string $type
Определения Event.php:13
string $subSection
Определения Event.php:15
AnalyticsEvent $event
Определения Event.php:11
setP2(?string $p2)
Определения Event.php:145
static convertUnderscore(string $string)
Определения Event.php:46
setP1(?string $p1)
Определения Event.php:139
string $element
Определения Event.php:16
$event
Определения prolog_after.php:141