Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
event.php
1
<?php
2
namespace
Bitrix\Main
;
3
4
class
Event
5
{
6
protected
$moduleId
;
7
protected
$type
;
8
protected
$parameters
= array();
10
protected
$parametersLoader
=
null
;
11
protected
$filter
=
null
;
12
protected
$sender
=
null
;
13
14
protected
$debugMode
=
false
;
15
protected
$debugInfo
= array();
16
18
protected
$results
= array();
19
21
protected
$exceptions
= array();
22
29
public
function
__construct
(
$moduleId
,
$type
,
$parameters
= array(),
$filter
=
null
)
30
{
31
$this->moduleId =
$moduleId
;
32
$this->type =
$type
;
33
$this->
setParameters
(
$parameters
);
34
$this->
setFilter
(
$filter
);
35
36
$this->debugMode =
false
;
37
}
38
39
public
function
getModuleId
()
40
{
41
return
$this->moduleId
;
42
}
43
44
public
function
getEventType
()
45
{
46
return
$this->type
;
47
}
48
49
public
function
setParameters
(
$parameters
)
50
{
51
if
(is_array(
$parameters
))
52
{
53
$this->parameters =
$parameters
;
54
}
55
elseif (
$parameters
instanceof \Closure)
56
{
57
$this->parameters =
null
;
58
$this->parametersLoader =
$parameters
;
59
}
60
else
61
{
62
throw
new
ArgumentTypeException
(
"parameter"
,
"array or closure, which returns array"
);
63
}
64
}
65
66
public
function
getParameters
()
67
{
68
$this->
loadParameters
();
69
70
return
$this->parameters
;
71
}
72
73
public
function
setParameter
($key, $value)
74
{
75
$this->
loadParameters
();
76
77
$this->parameters[$key] = $value;
78
}
79
80
public
function
getParameter
($key)
81
{
82
$this->
loadParameters
();
83
84
if
(isset($this->parameters[$key]))
85
return
$this->parameters[$key];
86
87
return
null
;
88
}
89
90
protected
function
loadParameters
()
91
{
92
if
(!$this->parametersLoader)
93
{
94
return
false
;
95
}
96
97
$this->
setParameters
(call_user_func_array($this->parametersLoader, array()));
98
$this->parametersLoader =
null
;
99
100
return
true
;
101
}
102
103
public
function
setFilter
(
$filter
)
104
{
105
if
(!is_array(
$filter
))
106
{
107
if
(empty(
$filter
))
108
$filter
=
null
;
109
else
110
$filter
= array(
$filter
);
111
}
112
113
$this->filter =
$filter
;
114
}
115
116
public
function
getFilter
()
117
{
118
return
$this->filter
;
119
}
120
124
public
function
getResults
()
125
{
126
return
$this->results
;
127
}
128
129
public
function
addResult
(
EventResult
$result)
130
{
131
$this->results[] = $result;
132
}
133
134
public
function
getSender
()
135
{
136
return
$this->sender
;
137
}
138
139
public
function
send
(
$sender
=
null
)
140
{
141
$this->sender =
$sender
;
142
EventManager::getInstance
()->send($this);
143
}
144
145
public
function
addException
(\Exception $exception)
146
{
147
$this->exceptions[] = $exception;
148
}
149
150
public
function
getExceptions
()
151
{
152
return
$this->exceptions
;
153
}
154
155
public
function
turnDebugOn
()
156
{
157
$this->debugMode =
true
;
158
}
159
160
public
function
isDebugOn
()
161
{
162
return
$this->debugMode
;
163
}
164
165
public
function
addDebugInfo
($ar)
166
{
167
if
(!$this->debugMode)
168
return
;
169
170
$this->debugInfo[] = $ar;
171
}
172
173
public
function
getDebugInfo
()
174
{
175
return
$this->debugInfo
;
176
}
177
}
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Event\getParameters
getParameters()
Definition
event.php:66
Bitrix\Main\Event\loadParameters
loadParameters()
Definition
event.php:90
Bitrix\Main\Event\setParameters
setParameters($parameters)
Definition
event.php:49
Bitrix\Main\Event\$results
$results
Definition
event.php:18
Bitrix\Main\Event\getFilter
getFilter()
Definition
event.php:116
Bitrix\Main\Event\getResults
getResults()
Definition
event.php:124
Bitrix\Main\Event\$parametersLoader
$parametersLoader
Definition
event.php:10
Bitrix\Main\Event\getSender
getSender()
Definition
event.php:134
Bitrix\Main\Event\$debugMode
$debugMode
Definition
event.php:14
Bitrix\Main\Event\setParameter
setParameter($key, $value)
Definition
event.php:73
Bitrix\Main\Event\$debugInfo
$debugInfo
Definition
event.php:15
Bitrix\Main\Event\setFilter
setFilter($filter)
Definition
event.php:103
Bitrix\Main\Event\addException
addException(\Exception $exception)
Definition
event.php:145
Bitrix\Main\Event\send
send($sender=null)
Definition
event.php:139
Bitrix\Main\Event\turnDebugOn
turnDebugOn()
Definition
event.php:155
Bitrix\Main\Event\getEventType
getEventType()
Definition
event.php:44
Bitrix\Main\Event\$exceptions
$exceptions
Definition
event.php:21
Bitrix\Main\Event\__construct
__construct($moduleId, $type, $parameters=array(), $filter=null)
Definition
event.php:29
Bitrix\Main\Event\$type
$type
Definition
event.php:7
Bitrix\Main\Event\addResult
addResult(EventResult $result)
Definition
event.php:129
Bitrix\Main\Event\$filter
$filter
Definition
event.php:11
Bitrix\Main\Event\isDebugOn
isDebugOn()
Definition
event.php:160
Bitrix\Main\Event\$parameters
$parameters
Definition
event.php:8
Bitrix\Main\Event\getDebugInfo
getDebugInfo()
Definition
event.php:173
Bitrix\Main\Event\getModuleId
getModuleId()
Definition
event.php:39
Bitrix\Main\Event\$moduleId
$moduleId
Definition
event.php:6
Bitrix\Main\Event\getParameter
getParameter($key)
Definition
event.php:80
Bitrix\Main\Event\$sender
$sender
Definition
event.php:12
Bitrix\Main\Event\getExceptions
getExceptions()
Definition
event.php:150
Bitrix\Main\Event\addDebugInfo
addDebugInfo($ar)
Definition
event.php:165
Bitrix\Main\EventManager\getInstance
static getInstance()
Definition
eventmanager.php:33
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Main
modules
main
lib
event.php
Создано системой
1.10.0