Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
action.php
1
<?php
2
3
namespace
Bitrix\Main\Engine
;
4
5
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\ErrorCollection
;
8
use
Bitrix\Main\Errorable
;
9
use
Bitrix\Main\SystemException
;
10
16
class
Action
implements
Errorable
17
{
19
protected
$binder
;
21
protected
$errorCollection
;
23
protected
$controller
;
25
protected
$config
;
27
protected
$name
;
28
29
public
function
__construct
(
$name
,
Controller
$controller
,
$config
= array())
30
{
31
$this->errorCollection =
new
ErrorCollection
;
32
$this->controller =
$controller
;
33
$this->config =
$config
;
34
$this->name =
$name
;
35
36
if
(isset(
$config
[
'configure'
]))
37
{
38
$this->
configure
(
$config
[
'configure'
]);
39
}
40
41
$this->
init
();
42
}
43
50
public
function
configure
($params)
51
{}
52
53
protected
function
init
()
54
{}
55
62
final
public
function
getArguments
()
63
{
64
$binder
= $this->
buildBinder
()->getBinder();
65
66
return
$binder
->getMethodParams();
67
}
68
79
final
public
function
setArguments
(array $arguments)
80
{
81
$binder
= $this->
buildBinder
()->getBinder();
82
83
return
$binder
->setMethodParams($arguments);
84
}
85
86
protected
function
buildBinder
()
87
{
88
if
($this->binder ===
null
)
89
{
90
if
(!method_exists($this,
'run'
))
91
{
92
throw
new
SystemException
(static::className() .
' must implement run()'
);
93
}
94
95
$controller
= $this->
getController
();
96
$this->binder = AutoWire\ControllerBinder::buildForMethod($this,
'run'
)
97
->setController(
$controller
)
98
->setSourcesParametersToMap(
$controller
->getSourceParametersList())
99
->setAutoWiredParameters(
100
array_filter(array_merge(
101
[
$controller
->getPrimaryAutoWiredParameter()],
102
$controller
->getAutoWiredParameters()
103
))
104
)
105
;
106
}
107
108
return
$this;
109
}
110
111
public
function
runWithSourceParametersList
()
112
{
113
$binder
= $this->
buildBinder
()->getBinder();
114
if
($this->
onBeforeRun
())
115
{
117
$result =
$binder
->invoke();
118
119
$this->
onAfterRun
();
120
121
return
$result;
122
}
123
124
return
null
;
125
}
126
130
final
public
function
getBinder
()
131
{
132
return
$this->binder
;
133
}
134
138
final
public
function
getController
()
139
{
140
return
$this->controller
;
141
}
142
146
final
public
function
getName
()
147
{
148
return
$this->name
;
149
}
150
154
final
public
function
getConfig
()
155
{
156
return
$this->config
;
157
}
158
159
protected
function
onBeforeRun
()
160
{
161
return
true
;
162
}
163
164
protected
function
onAfterRun
()
165
{
166
}
167
168
final
public
function
getCurrentUser
()
169
{
170
return
$this->
getController
()->getCurrentUser();
171
}
172
180
public
function
convertKeysToCamelCase
($data)
181
{
182
return
$this->
getController
()->convertKeysToCamelCase($data);
183
}
184
189
final
public
static
function
className
()
190
{
191
return
get_called_class();
192
}
193
200
protected
function
addError
(
Error
$error)
201
{
202
$this->errorCollection[] = $error;
203
204
return
$this;
205
}
206
213
protected
function
addErrors
(array $errors)
214
{
215
$this->errorCollection->add($errors);
216
217
return
$this;
218
}
219
224
final
public
function
getErrors
()
225
{
226
return
$this->errorCollection->toArray();
227
}
228
234
final
public
function
getErrorByCode
($code)
235
{
236
return
$this->errorCollection->getErrorByCode($code);
237
}
238
}
Bitrix\Main\Engine\Action
Definition
action.php:17
Bitrix\Main\Engine\Action\addError
addError(Error $error)
Definition
action.php:200
Bitrix\Main\Engine\Action\configure
configure($params)
Definition
action.php:50
Bitrix\Main\Engine\Action\buildBinder
buildBinder()
Definition
action.php:86
Bitrix\Main\Engine\Action\onBeforeRun
onBeforeRun()
Definition
action.php:159
Bitrix\Main\Engine\Action\getArguments
getArguments()
Definition
action.php:62
Bitrix\Main\Engine\Action\convertKeysToCamelCase
convertKeysToCamelCase($data)
Definition
action.php:180
Bitrix\Main\Engine\Action\addErrors
addErrors(array $errors)
Definition
action.php:213
Bitrix\Main\Engine\Action\$controller
$controller
Definition
action.php:23
Bitrix\Main\Engine\Action\getName
getName()
Definition
action.php:146
Bitrix\Main\Engine\Action\$config
$config
Definition
action.php:25
Bitrix\Main\Engine\Action\__construct
__construct($name, Controller $controller, $config=array())
Definition
action.php:29
Bitrix\Main\Engine\Action\init
init()
Definition
action.php:53
Bitrix\Main\Engine\Action\setArguments
setArguments(array $arguments)
Definition
action.php:79
Bitrix\Main\Engine\Action\getConfig
getConfig()
Definition
action.php:154
Bitrix\Main\Engine\Action\getErrors
getErrors()
Definition
action.php:224
Bitrix\Main\Engine\Action\$errorCollection
$errorCollection
Definition
action.php:21
Bitrix\Main\Engine\Action\onAfterRun
onAfterRun()
Definition
action.php:164
Bitrix\Main\Engine\Action\getBinder
getBinder()
Definition
action.php:130
Bitrix\Main\Engine\Action\$binder
$binder
Definition
action.php:19
Bitrix\Main\Engine\Action\getController
getController()
Definition
action.php:138
Bitrix\Main\Engine\Action\$name
$name
Definition
action.php:27
Bitrix\Main\Engine\Action\getErrorByCode
getErrorByCode($code)
Definition
action.php:234
Bitrix\Main\Engine\Action\runWithSourceParametersList
runWithSourceParametersList()
Definition
action.php:111
Bitrix\Main\Engine\Action\className
static className()
Definition
action.php:189
Bitrix\Main\Engine\Action\getCurrentUser
getCurrentUser()
Definition
action.php:168
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\Errorable
Definition
errorable.php:6
Bitrix\Main\Engine
Definition
action.php:3
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
modules
main
lib
engine
action.php
Создано системой
1.10.0