1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
action.php
См. документацию.
1<?php
2
4
5
10
16class Action implements Errorable
17{
19 protected $binder;
23 protected $controller;
25 protected $config;
27 protected $name;
28
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
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
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}
addError(Error $error)
Определения action.php:200
configure($params)
Определения action.php:50
buildBinder()
Определения action.php:86
onBeforeRun()
Определения action.php:159
getArguments()
Определения action.php:62
convertKeysToCamelCase($data)
Определения action.php:180
addErrors(array $errors)
Определения action.php:213
$controller
Определения action.php:23
getName()
Определения action.php:146
__construct($name, Controller $controller, $config=array())
Определения action.php:29
init()
Определения action.php:53
setArguments(array $arguments)
Определения action.php:79
getConfig()
Определения action.php:154
getErrors()
Определения action.php:224
$errorCollection
Определения action.php:21
onAfterRun()
Определения action.php:164
getBinder()
Определения action.php:130
getController()
Определения action.php:138
getErrorByCode($code)
Определения action.php:234
runWithSourceParametersList()
Определения action.php:111
static className()
Определения action.php:189
getCurrentUser()
Определения action.php:168
static buildForMethod($instance, $method, $configuration=[])
Определения binder.php:53
Определения error.php:15
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
Определения action.php:3
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$error
Определения subscription_card_product.php:20