Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
event.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Internals\Counter\Event
;
4
11
class
Event
12
{
13
/* @var string $type */
14
private
$type;
15
/* @var array $data */
16
private
$data = [];
17
22
public
function
__construct
(
string
$type =
''
)
23
{
24
$this->type = $type;
25
}
26
31
public
function
setData
(array $data = []): self
32
{
33
$this->data = $this->prepareData($data);
34
return
$this;
35
}
36
40
public
function
getType
(): string
41
{
42
return
$this->type;
43
}
44
48
public
function
getData
(): array
49
{
50
return
$this->data;
51
}
52
56
public
function
getUserId
(): int
57
{
58
$userId = 0;
59
60
switch
($this->type)
61
{
62
case
EventDictionary::EVENT_WORKGROUP_DELETE
:
63
case
EventDictionary::EVENT_WORKGROUP_USER_ADD
:
64
case
EventDictionary::EVENT_WORKGROUP_USER_UPDATE
:
65
case
EventDictionary::EVENT_WORKGROUP_USER_DELETE
:
66
$userId = (int)$this->data[
'USER_ID'
];
67
break
;
68
}
69
70
return
$userId;
71
}
72
76
public
function
getGroupId
(): int
77
{
78
$groupId = 0;
79
80
switch
($this->type)
81
{
82
case
EventDictionary::EVENT_WORKGROUP_DELETE
:
83
case
EventDictionary::EVENT_WORKGROUP_USER_ADD
:
84
case
EventDictionary::EVENT_WORKGROUP_USER_UPDATE
:
85
case
EventDictionary::EVENT_WORKGROUP_USER_DELETE
:
86
$groupId = (int)$this->data[
'GROUP_ID'
];
87
break
;
88
}
89
90
return
$groupId;
91
}
92
96
public
function
getUsedRoles
(): array
97
{
98
$rolesList = [];
99
100
switch
($this->type)
101
{
102
case
EventDictionary::EVENT_WORKGROUP_USER_DELETE
:
103
case
EventDictionary::EVENT_WORKGROUP_USER_ADD
:
104
$rolesList[] = $this->data[
'ROLE'
];
105
break
;
106
case
EventDictionary::EVENT_WORKGROUP_USER_UPDATE
:
107
$rolesList[] = $this->data[
'ROLE_OLD'
];
108
$rolesList[] = $this->data[
'ROLE_NEW'
];
109
break
;
110
}
111
112
return
$rolesList;
113
}
114
118
public
function
getInitiatedByType
(): string
119
{
120
$initiatedByType =
null
;
121
122
switch
($this->type)
123
{
124
case
EventDictionary::EVENT_WORKGROUP_USER_ADD
:
125
case
EventDictionary::EVENT_WORKGROUP_USER_UPDATE
:
126
case
EventDictionary::EVENT_WORKGROUP_USER_DELETE
:
127
$initiatedByType = $this->data[
'INITIATED_BY_TYPE'
];
128
break
;
129
}
130
131
return
$initiatedByType;
132
}
133
138
private
function
prepareData(array $data = []): array
139
{
140
$validFields = [
141
'USER_ID'
,
142
'GROUP_ID'
,
143
'ROLE'
,
144
'ROLE_OLD'
,
145
'ROLE_NEW'
,
146
'INITIATED_BY_TYPE'
,
147
'RELATION_ID'
,
148
];
149
150
foreach
($data as $key => $row)
151
{
152
if
(!in_array($key, $validFields,
true
))
153
{
154
unset($data[$key]);
155
}
156
}
157
158
return
$data;
159
}
160
}
Bitrix\Socialnetwork\Internals\Counter\Event\EventDictionary\EVENT_WORKGROUP_DELETE
const EVENT_WORKGROUP_DELETE
Definition
eventdictionary.php:15
Bitrix\Socialnetwork\Internals\Counter\Event\EventDictionary\EVENT_WORKGROUP_USER_UPDATE
const EVENT_WORKGROUP_USER_UPDATE
Definition
eventdictionary.php:17
Bitrix\Socialnetwork\Internals\Counter\Event\EventDictionary\EVENT_WORKGROUP_USER_ADD
const EVENT_WORKGROUP_USER_ADD
Definition
eventdictionary.php:16
Bitrix\Socialnetwork\Internals\Counter\Event\EventDictionary\EVENT_WORKGROUP_USER_DELETE
const EVENT_WORKGROUP_USER_DELETE
Definition
eventdictionary.php:18
Bitrix\Socialnetwork\Internals\Counter\Event\Event
Definition
event.php:12
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getUserId
getUserId()
Definition
event.php:56
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getUsedRoles
getUsedRoles()
Definition
event.php:96
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getGroupId
getGroupId()
Definition
event.php:76
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getData
getData()
Definition
event.php:48
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getType
getType()
Definition
event.php:40
Bitrix\Socialnetwork\Internals\Counter\Event\Event\__construct
__construct(string $type='')
Definition
event.php:22
Bitrix\Socialnetwork\Internals\Counter\Event\Event\setData
setData(array $data=[])
Definition
event.php:31
Bitrix\Socialnetwork\Internals\Counter\Event\Event\getInitiatedByType
getInitiatedByType()
Definition
event.php:118
Bitrix\Socialnetwork\Internals\Counter\Event
Definition
event.php:3
modules
socialnetwork
lib
internals
counter
event
event.php
Создано системой
1.10.0