15542 |
efrain |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
7 |
|
15542 |
efrain |
8 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use Laminas\View\Model\ViewModel;
|
|
|
11 |
use Laminas\View\Model\JsonModel;
|
|
|
12 |
use LeadersLinked\Library\Functions;
|
|
|
13 |
use LeadersLinked\Mapper\EngagementRewardMapper;
|
|
|
14 |
use LeadersLinked\Model\EngagementReward;
|
|
|
15 |
use LeadersLinked\Library\Image;
|
|
|
16 |
use LeadersLinked\Form\Engagement\EngagementRewardAddForm;
|
|
|
17 |
use LeadersLinked\Form\Engagement\EngagementRewardEditForm;
|
17002 |
efrain |
18 |
use LeadersLinked\Library\Storage;
|
15542 |
efrain |
19 |
|
|
|
20 |
class EngagementRewardController extends AbstractActionController
|
|
|
21 |
{
|
|
|
22 |
/**
|
|
|
23 |
*
|
16769 |
efrain |
24 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
15542 |
efrain |
25 |
*/
|
|
|
26 |
private $adapter;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
*
|
16769 |
efrain |
30 |
* @var \LeadersLinked\Cache\CacheInterface
|
15542 |
efrain |
31 |
*/
|
16769 |
efrain |
32 |
private $cache;
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
*
|
|
|
37 |
* @var \Laminas\Log\LoggerInterface
|
|
|
38 |
*/
|
15542 |
efrain |
39 |
private $logger;
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
*
|
|
|
43 |
* @var array
|
|
|
44 |
*/
|
|
|
45 |
private $config;
|
|
|
46 |
|
16769 |
efrain |
47 |
|
15542 |
efrain |
48 |
/**
|
|
|
49 |
*
|
16769 |
efrain |
50 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
51 |
*/
|
|
|
52 |
private $translator;
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
*
|
|
|
57 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
58 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
59 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
15542 |
efrain |
60 |
* @param array $config
|
16769 |
efrain |
61 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
15542 |
efrain |
62 |
*/
|
16769 |
efrain |
63 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
15542 |
efrain |
64 |
{
|
16769 |
efrain |
65 |
$this->adapter = $adapter;
|
|
|
66 |
$this->cache = $cache;
|
|
|
67 |
$this->logger = $logger;
|
|
|
68 |
$this->config = $config;
|
|
|
69 |
$this->translator = $translator;
|
15542 |
efrain |
70 |
}
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
public function indexAction()
|
|
|
74 |
{
|
|
|
75 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
76 |
$currentNetwork = $currentNetworkPlugin->getNetwork();
|
|
|
77 |
|
|
|
78 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
79 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
80 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
81 |
|
|
|
82 |
$request = $this->getRequest();
|
|
|
83 |
if($request->isGet()) {
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
$headers = $request->getHeaders();
|
|
|
87 |
|
|
|
88 |
$isJson = false;
|
|
|
89 |
if($headers->has('Accept')) {
|
|
|
90 |
$accept = $headers->get('Accept');
|
|
|
91 |
|
|
|
92 |
$prioritized = $accept->getPrioritized();
|
|
|
93 |
|
|
|
94 |
foreach($prioritized as $key => $value) {
|
|
|
95 |
$raw = trim($value->getRaw());
|
|
|
96 |
|
|
|
97 |
if(!$isJson) {
|
|
|
98 |
$isJson = strpos($raw, 'json');
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
if($isJson) {
|
|
|
105 |
$search = $this->params()->fromQuery('search', []);
|
16766 |
efrain |
106 |
$search = empty($search['value']) ? '' : Functions::sanitizeFilterString($search['value']);
|
15542 |
efrain |
107 |
|
|
|
108 |
$page = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
109 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
110 |
$order = $this->params()->fromQuery('order', []);
|
|
|
111 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
16766 |
efrain |
112 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(Functions::sanitizeFilterString($order[0]['dir']));
|
15542 |
efrain |
113 |
|
|
|
114 |
$fields = ['name'];
|
|
|
115 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'name';
|
|
|
116 |
|
|
|
117 |
if(!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
118 |
$order_direction = 'ASC';
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
$recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
|
|
|
122 |
$paginator = $recompensaMapper->fetchAllDataTable($currentCompany->id, $search, $page, $records_x_page, $order_field, $order_direction);
|
|
|
123 |
|
17018 |
efrain |
124 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
17002 |
efrain |
125 |
$path = $storage->getPathEngagementReward();
|
15542 |
efrain |
126 |
|
|
|
127 |
$items = [];
|
|
|
128 |
$records = $paginator->getCurrentItems();
|
|
|
129 |
foreach($records as $record)
|
|
|
130 |
{
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
$item = [
|
|
|
135 |
'name' => $record->name,
|
|
|
136 |
'status' => $record->status,
|
|
|
137 |
'points' => $record->points,
|
17002 |
efrain |
138 |
'image' => $storage->getGenericImage($path, $record->uuid, $record->image),
|
15542 |
efrain |
139 |
'actions' => [
|
|
|
140 |
'link_edit' => $this->url()->fromRoute('engagement/rewards/edit', ['id' => $record->uuid ]),
|
|
|
141 |
'link_delete' => $this->url()->fromRoute('engagement/rewards/delete', ['id' => $record->uuid ]),
|
|
|
142 |
]
|
|
|
143 |
];
|
|
|
144 |
|
|
|
145 |
array_push($items, $item);
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
return new JsonModel([
|
|
|
149 |
'success' => true,
|
|
|
150 |
'data' => [
|
|
|
151 |
'items' => $items,
|
|
|
152 |
'total' => $paginator->getTotalItemCount(),
|
|
|
153 |
]
|
|
|
154 |
]);
|
|
|
155 |
} else {
|
|
|
156 |
$target_size = $this->config['leaderslinked.image_sizes.marketplace'];
|
|
|
157 |
|
|
|
158 |
$formAdd = new EngagementRewardAddForm();
|
|
|
159 |
$formEdit = new EngagementRewardEditForm();
|
|
|
160 |
|
|
|
161 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
162 |
$viewModel = new ViewModel();
|
|
|
163 |
$viewModel->setTemplate('leaders-linked/engagement-rewards/index.phtml');
|
|
|
164 |
$viewModel->setVariables([
|
|
|
165 |
'formAdd' => $formAdd,
|
|
|
166 |
'formEdit' => $formEdit,
|
|
|
167 |
'targetSize'=> $target_size,
|
|
|
168 |
]);
|
|
|
169 |
return $viewModel ;
|
|
|
170 |
}
|
|
|
171 |
} else {
|
|
|
172 |
return new JsonModel([
|
|
|
173 |
'success' => false,
|
|
|
174 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
175 |
]);;
|
|
|
176 |
}
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
public function addAction()
|
|
|
182 |
{
|
|
|
183 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
184 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
185 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
186 |
|
|
|
187 |
$request = $this->getRequest();
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
if($request->isPost()) {
|
|
|
191 |
$form = new EngagementRewardAddForm();
|
|
|
192 |
$dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
|
|
193 |
$dataPost['status'] = empty($dataPost['status']) ? EngagementReward::STATUS_INACTIVE : $dataPost['status'];
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
$form->setData($dataPost);
|
|
|
197 |
|
|
|
198 |
if($form->isValid()) {
|
|
|
199 |
$dataPost = (array) $form->getData();
|
|
|
200 |
|
|
|
201 |
$recompensa = new EngagementReward();
|
|
|
202 |
$recompensa->company_id = $currentCompany->id;
|
|
|
203 |
$recompensa->name = $dataPost['name'];
|
|
|
204 |
$recompensa->points = $dataPost['points'];
|
|
|
205 |
$recompensa->status = $dataPost['status'];
|
|
|
206 |
$recompensa->image = '';
|
|
|
207 |
|
|
|
208 |
$recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
|
|
|
209 |
if($recompensaMapper->insert($recompensa)) {
|
|
|
210 |
|
|
|
211 |
$recompensa = $recompensaMapper->fetchOne($recompensa->id);
|
|
|
212 |
|
|
|
213 |
$target_size = $this->config['leaderslinked.image_sizes.marketplace'];
|
|
|
214 |
list($target_width , $target_height) = explode('x', $target_size);
|
|
|
215 |
|
|
|
216 |
$target_path = $this->config['leaderslinked.fullpath.engagement_reward'] . $recompensa->uuid;
|
|
|
217 |
if(!file_exists($target_path)) {
|
|
|
218 |
mkdir($target_path, 0755, true);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
$files = $this->getRequest()->getFiles()->toArray();
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
if(isset($files['image']) && empty($files['image']['error'])) {
|
|
|
226 |
$tmp_filename = $files['image']['tmp_name'];
|
|
|
227 |
$filename = explode('.', $files['image']['name']);
|
|
|
228 |
$filename = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
|
|
|
229 |
|
|
|
230 |
$crop_to_dimensions = true;
|
17002 |
efrain |
231 |
$unlink_source = true;
|
15542 |
efrain |
232 |
|
17002 |
efrain |
233 |
$image = Image::getInstance($this->config);
|
|
|
234 |
$target_path = $image->getStorage()->getPathEngagementReward();
|
15542 |
efrain |
235 |
|
17018 |
efrain |
236 |
if($image->uploadProcessChangeSize($tmp_filename, $target_path, $recompensa->uuid, $filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
|
15542 |
efrain |
237 |
$recompensa->image = $filename;
|
|
|
238 |
$recompensaMapper->update($recompensa);
|
|
|
239 |
}
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
$this->logger->info('Se agrego la recompensa ' . $recompensa->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
244 |
|
|
|
245 |
$data = [
|
|
|
246 |
'success' => true,
|
|
|
247 |
'data' => 'LABEL_RECORD_ADDED'
|
|
|
248 |
];
|
|
|
249 |
} else {
|
|
|
250 |
$data = [
|
|
|
251 |
'success' => false,
|
|
|
252 |
'data' => $recompensaMapper->getError()
|
|
|
253 |
];
|
|
|
254 |
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
return new JsonModel($data);
|
|
|
258 |
|
|
|
259 |
} else {
|
|
|
260 |
$messages = [];
|
|
|
261 |
$form_messages = (array) $form->getMessages();
|
|
|
262 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
263 |
{
|
|
|
264 |
|
|
|
265 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
return new JsonModel([
|
|
|
269 |
'success' => false,
|
|
|
270 |
'data' => $messages
|
|
|
271 |
]);
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
} else {
|
|
|
275 |
$data = [
|
|
|
276 |
'success' => false,
|
|
|
277 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
278 |
];
|
|
|
279 |
|
|
|
280 |
return new JsonModel($data);
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
return new JsonModel($data);
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
/**
|
|
|
287 |
*
|
|
|
288 |
* Borrar un perfil excepto el público
|
|
|
289 |
* @return \Laminas\View\Model\JsonModel
|
|
|
290 |
*/
|
|
|
291 |
public function deleteAction()
|
|
|
292 |
{
|
|
|
293 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
294 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
295 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
296 |
|
|
|
297 |
$request = $this->getRequest();
|
|
|
298 |
$id = $this->params()->fromRoute('id');
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
$recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
|
|
|
303 |
$recompensa = $recompensaMapper->fetchOneByUuid($id);
|
|
|
304 |
if(!$recompensa) {
|
|
|
305 |
return new JsonModel([
|
|
|
306 |
'success' => false,
|
|
|
307 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
308 |
]);
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
if($recompensa->company_id != $currentCompany->id) {
|
|
|
312 |
return new JsonModel([
|
|
|
313 |
'success' => false,
|
|
|
314 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
315 |
]);
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
if($request->isPost()) {
|
|
|
319 |
|
|
|
320 |
$result = $recompensaMapper->delete($recompensa);
|
|
|
321 |
if($result) {
|
|
|
322 |
$this->logger->info('Se borro la recompensa : ' . $recompensa->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
323 |
|
17002 |
efrain |
324 |
|
|
|
325 |
|
15542 |
efrain |
326 |
if($recompensa->image) {
|
17018 |
efrain |
327 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
17002 |
efrain |
328 |
$target_path = $storage->getPathEngagementReward();
|
|
|
329 |
|
|
|
330 |
$storage->deleteFile($target_path, $recompensa->uuid, $recompensa->image);
|
15542 |
efrain |
331 |
}
|
|
|
332 |
|
|
|
333 |
$data = [
|
|
|
334 |
'success' => true,
|
|
|
335 |
'data' => 'LABEL_RECORD_DELETED'
|
|
|
336 |
];
|
|
|
337 |
} else {
|
|
|
338 |
|
|
|
339 |
$data = [
|
|
|
340 |
'success' => false,
|
|
|
341 |
'data' => $recompensaMapper->getError()
|
|
|
342 |
];
|
|
|
343 |
|
|
|
344 |
return new JsonModel($data);
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
} else {
|
|
|
348 |
$data = [
|
|
|
349 |
'success' => false,
|
|
|
350 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
351 |
];
|
|
|
352 |
|
|
|
353 |
return new JsonModel($data);
|
|
|
354 |
}
|
|
|
355 |
|
|
|
356 |
return new JsonModel($data);
|
|
|
357 |
}
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
public function editAction()
|
|
|
361 |
{
|
|
|
362 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
363 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
364 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
365 |
|
|
|
366 |
$request = $this->getRequest();
|
|
|
367 |
$id = $this->params()->fromRoute('id');
|
|
|
368 |
|
|
|
369 |
|
|
|
370 |
$recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
|
|
|
371 |
$recompensa = $recompensaMapper->fetchOneByUuid($id);
|
|
|
372 |
if(!$recompensa) {
|
|
|
373 |
return new JsonModel([
|
|
|
374 |
'success' => false,
|
|
|
375 |
'data' => 'ERROR_RECORD_NOT_FOUND'
|
|
|
376 |
]);
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
if($recompensa->company_id != $currentCompany->id) {
|
|
|
381 |
return new JsonModel([
|
|
|
382 |
'success' => false,
|
|
|
383 |
'data' => 'ERROR_UNAUTHORIZED'
|
|
|
384 |
]);
|
|
|
385 |
}
|
|
|
386 |
|
|
|
387 |
if($request->isGet()) {
|
17018 |
efrain |
388 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
17002 |
efrain |
389 |
$path = $storage->getPathEngagementReward();
|
|
|
390 |
|
15542 |
efrain |
391 |
$data = [
|
|
|
392 |
'success' => true,
|
|
|
393 |
'data' => [
|
|
|
394 |
'name' => $recompensa->name,
|
|
|
395 |
'status' => $recompensa->status,
|
|
|
396 |
'points' => $recompensa->points,
|
17002 |
efrain |
397 |
'image' => $recompensa->image ? $storage->getGenericImage($path, $recompensa->uuid, $recompensa->image) : '',
|
15542 |
efrain |
398 |
]
|
|
|
399 |
];
|
|
|
400 |
|
|
|
401 |
return new JsonModel($data);
|
|
|
402 |
}
|
|
|
403 |
else if($request->isPost()) {
|
|
|
404 |
$form = new EngagementRewardEditForm();
|
|
|
405 |
$dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
|
|
406 |
$dataPost['status'] = empty($dataPost['status']) ? EngagementReward::STATUS_INACTIVE : $dataPost['status'];
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
$form->setData($dataPost);
|
|
|
410 |
|
|
|
411 |
if($form->isValid()) {
|
|
|
412 |
$dataPost = (array) $form->getData();
|
|
|
413 |
|
|
|
414 |
$recompensa->name = $dataPost['name'];
|
|
|
415 |
$recompensa->points = $dataPost['points'];
|
|
|
416 |
$recompensa->status = $dataPost['status'];
|
|
|
417 |
|
|
|
418 |
if($recompensaMapper->update($recompensa)) {
|
|
|
419 |
|
|
|
420 |
$target_size = $this->config['leaderslinked.image_sizes.marketplace'];
|
|
|
421 |
list($target_width , $target_height) = explode('x', $target_size);
|
|
|
422 |
|
|
|
423 |
$target_path = $this->config['leaderslinked.fullpath.engagement_reward'] . $recompensa->uuid;
|
|
|
424 |
if(!file_exists($target_path)) {
|
|
|
425 |
mkdir($target_path, 0755, true);
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
$files = $this->getRequest()->getFiles()->toArray();
|
|
|
430 |
if(isset($files['image']) && empty($files['image']['error'])) {
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
$tmp_filename = $files['image']['tmp_name'];
|
|
|
434 |
$filename = explode('.', $files['image']['name']);
|
|
|
435 |
$filename = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
|
|
|
436 |
|
|
|
437 |
$crop_to_dimensions = true;
|
17002 |
efrain |
438 |
$unlink_source = true;
|
|
|
439 |
|
|
|
440 |
$image = Image::getInstance($this->config);
|
|
|
441 |
|
17018 |
efrain |
442 |
if($image->uploadProcessChangeSize($tmp_filename, $target_path, $recompensa->uuid, $filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
|
15542 |
efrain |
443 |
|
|
|
444 |
|
|
|
445 |
if($recompensa->image) {
|
17002 |
efrain |
446 |
$target_path = $image->getStorage()->getPathEngagementReward();
|
|
|
447 |
$image->getStorage()->deleteFile($target_path, $recompensa->uuid, $recompensa->image);
|
15542 |
efrain |
448 |
}
|
|
|
449 |
|
|
|
450 |
$recompensa->image = $filename;
|
|
|
451 |
$recompensaMapper->update($recompensa);
|
|
|
452 |
}
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
$this->logger->info('Se edito la recompensa' . $recompensa->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
|
|
458 |
|
|
|
459 |
$data = [
|
|
|
460 |
'success' => true,
|
|
|
461 |
'data' => 'LABEL_RECORD_UPDATED'
|
|
|
462 |
];
|
|
|
463 |
} else {
|
|
|
464 |
$data = [
|
|
|
465 |
'success' => false,
|
|
|
466 |
'data' => $recompensaMapper->getError()
|
|
|
467 |
];
|
|
|
468 |
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
return new JsonModel($data);
|
|
|
472 |
|
|
|
473 |
} else {
|
|
|
474 |
$messages = [];
|
|
|
475 |
$form_messages = (array) $form->getMessages();
|
|
|
476 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
477 |
{
|
|
|
478 |
|
|
|
479 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
return new JsonModel([
|
|
|
483 |
'success' => false,
|
|
|
484 |
'data' => $messages
|
|
|
485 |
]);
|
|
|
486 |
}
|
|
|
487 |
} else {
|
|
|
488 |
$data = [
|
|
|
489 |
'success' => false,
|
|
|
490 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
491 |
];
|
|
|
492 |
|
|
|
493 |
return new JsonModel($data);
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
return new JsonModel($data);
|
|
|
497 |
}
|
|
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
|
502 |
}
|