Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1468 eleazar 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Controller;
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
9
use Laminas\Mvc\Controller\AbstractActionController;
10
use Laminas\Log\LoggerInterface;
11
use Laminas\View\Model\ViewModel;
12
use Laminas\View\Model\JsonModel;
1471 eleazar 13
use LeadersLinked\Form\RecruitmentSelectionCandidateFormForm;
1468 eleazar 14
use LeadersLinked\Library\Functions;
1479 eleazar 15
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
1468 eleazar 16
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
17
use LeadersLinked\Model\RecruitmentSelectionCandidate;
18
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
19
use LeadersLinked\Model\RecruitmentSelectionVacancy;
20
use LeadersLinked\Mapper\BehaviorMapper;
1473 eleazar 21
use LeadersLinked\Mapper\UserMapper;
1468 eleazar 22
use LeadersLinked\Mapper\CompanyMapper;
23
use LeadersLinked\Model\Company;
1601 eleazar 24
use Laminas\Hydrator\ArraySerializableHydrator;
25
use Laminas\Db\ResultSet\HydratingResultSet;
26
use LeadersLinked\Mapper\QueryMapper;
27
use Laminas\Paginator\Adapter\DbSelect;
28
use Laminas\Paginator\Paginator;
1468 eleazar 29
 
1470 eleazar 30
class RecruitmentSelectionCandidateController extends AbstractActionController{
31
 
32
    /**
1468 eleazar 33
     *
34
     * @var AdapterInterface
35
     */
36
    private $adapter;
37
 
38
    /**
39
     *
40
     * @var AbstractAdapter
41
     */
42
    private $cache;
43
 
44
    /**
45
     *
46
     * @var  LoggerInterface
47
     */
48
    private $logger;
49
 
50
    /**
51
     *
52
     * @var array
53
     */
54
    private $config;
55
 
56
    /**
57
     *
58
     * @param AdapterInterface $adapter
59
     * @param AbstractAdapter $cache
60
     * @param LoggerInterface $logger
61
     * @param array $config
62
     */
63
    public function __construct($adapter, $cache, $logger, $config) {
64
        $this->adapter = $adapter;
65
        $this->cache = $cache;
66
        $this->logger = $logger;
67
        $this->config = $config;
68
    }
69
 
70
    public function indexAction() {
71
        $currentUserPlugin = $this->plugin('currentUserPlugin');
72
        $currentUser = $currentUserPlugin->getUser();
73
        $currentCompany = $currentUserPlugin->getCompany();
74
 
75
        $request = $this->getRequest();
76
 
77
        if ($request->isGet()) {
78
 
79
            $headers = $request->getHeaders();
80
 
81
            $isJson = false;
82
            if ($headers->has('Accept')) {
83
                $accept = $headers->get('Accept');
84
 
85
                $prioritized = $accept->getPrioritized();
86
 
87
                foreach ($prioritized as $key => $value) {
88
                    $raw = trim($value->getRaw());
89
 
90
                    if (!$isJson) {
91
                        $isJson = strpos($raw, 'json');
92
                    }
93
                }
94
            }
95
 
96
            if ($isJson) {
1477 efrain 97
                //$form_uuid = filter_var($this->params()->fromQuery('form_uuid'), FILTER_SANITIZE_STRING);
1468 eleazar 98
 
1502 eleazar 99
                $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
1501 eleazar 100
 
1468 eleazar 101
                $data = [
102
                    'items' => [],
103
                    'total' => 0,
104
                ];
105
 
106
 
1477 efrain 107
                if (!$vacancy_uuid) {
1468 eleazar 108
                    return new JsonModel([
109
                        'success' => true,
110
                        'data' => $data
111
                    ]);
112
                }
113
 
114
 
1477 efrain 115
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
116
                $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
117
                if (! $vacancy) {
1468 eleazar 118
                    return new JsonModel([
119
                        'success' => true,
120
                        'data' => 'ERROR_FORM_NOT_FOUND'
121
                    ]);
122
                }
123
 
1477 efrain 124
                if ( $vacancy->company_id != $currentCompany->id) {
1468 eleazar 125
                    return new JsonModel([
126
                        'success' => true,
127
                        'data' => 'ERROR_UNAUTHORIZED'
128
                    ]);
129
                }
130
 
131
 
10095 stevensc 132
                $search = $this->params()->fromQuery('search');
133
                $search = empty($search) ? '' : filter_var($search, FILTER_SANITIZE_STRING);
1468 eleazar 134
 
15371 efrain 135
                $start = intval($this->params()->fromQuery('start', 0), 10);
1468 eleazar 136
                $records_x_page = intval($this->params()->fromQuery('length', 10), 10);
15371 efrain 137
                $page =  intval($start / $records_x_page);
138
                $page++;
139
 
1468 eleazar 140
                $order = $this->params()->fromQuery('order', []);
141
                $order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
142
                $order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
143
 
8890 eleazar 144
                $fields = ['uuid', 'first_name', 'last_name', 'email', 'status'];
1468 eleazar 145
                $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
146
 
147
                if (!in_array($order_direction, ['ASC', 'DESC'])) {
148
                    $order_direction = 'ASC';
149
                }
150
 
151
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
8786 eleazar 152
                $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/add');
153
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/edit');
154
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/candidates/delete');
1636 eleazar 155
                $allowEmail = $acl->isAllowed($currentUser->usertype_id, 'recruitment-and-selection/user-by-email');
1468 eleazar 156
 
1600 eleazar 157
                $queryMapper = QueryMapper::getInstance($this->adapter);
158
                $sql = $queryMapper->getSql();
159
                $select = $sql->select();
8889 eleazar 160
                $select->columns(['id', 'uuid', 'first_name', 'last_name', 'email', 'file', 'status']);
1600 eleazar 161
                $select->from(['tb1' => RecruitmentSelectionCandidateMapper::_TABLE]);
2681 eleazar 162
                $select->where->equalTo('tb1.vacancy_id', $vacancy->id);
1468 eleazar 163
 
1600 eleazar 164
                if($search) {
165
                    $select->where->nest()
166
                    ->like('first_name', '%' . $search . '%')
167
                    ->or->like('last_name', '%' . $search . '%')
168
                    ->or->like('email', '%' . $search . '%')
169
                    ->unnest();
170
                }
171
 
172
                $select->order($order_field . ' ' . $order_direction);
173
 
1468 eleazar 174
                $hydrator = new ArraySerializableHydrator();
175
                $resultset = new HydratingResultSet($hydrator);
176
 
177
                $adapter = new DbSelect($select, $sql, $resultset);
178
                $paginator = new Paginator($adapter);
179
                $paginator->setItemCountPerPage($records_x_page);
180
                $paginator->setCurrentPageNumber($page);
181
 
182
 
183
                $items = [];
184
                $records = $paginator->getCurrentItems();
4503 eleazar 185
 
6237 eleazar 186
 
1468 eleazar 187
                foreach ($records as $record) {
188
                    $params = [
1608 eleazar 189
                        'vacancy_uuid' => $vacancy->uuid,
190
                        'id' => $record['uuid'],
1468 eleazar 191
                    ];
192
 
8786 eleazar 193
                    $link_delete = $this->url()->fromRoute('recruitment-and-selection/candidates/delete', $params);
1624 eleazar 194
 
8786 eleazar 195
                    $link_edit = $this->url()->fromRoute('recruitment-and-selection/candidates/edit', $params);
1624 eleazar 196
 
1468 eleazar 197
                    $item = [
198
                        'uuid' => $record['uuid'],
199
                        'first_name' => $record['first_name'],
200
                        'last_name' => $record['last_name'],
201
                        'email' => $record['email'],
8889 eleazar 202
                        'status' => $record['status'],
1611 eleazar 203
                        // 'file' => $this->url()->fromRoute('storage', ['type' => 'recruitment_selection', 'code' => $record['uuid'], 'filename' => $record['file']]),
1468 eleazar 204
                        'actions' => [
1614 eleazar 205
                            'link_edit' => $allowEdit ? $link_edit : '',
1468 eleazar 206
                            'link_delete' => $allowDelete ? $link_delete : '',
207
                        ]
208
                    ];
209
 
210
                    array_push($items, $item);
211
                }
212
 
213
                $data['items'] = $items;
214
                $data['total'] = $paginator->getTotalItemCount();
215
 
216
 
217
                return new JsonModel([
218
                    'success' => true,
219
                    'data' => $data
220
                ]);
221
            } else {
222
                $form = new RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
10753 stevensc 223
 
10131 stevensc 224
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
10753 stevensc 225
                $vacancies = $vacancyMapper->fetchAllByCompanyId($currentCompany->id);
10132 stevensc 226
 
10131 stevensc 227
 
1468 eleazar 228
                $this->layout()->setTemplate('layout/layout-backend');
229
                $viewModel = new ViewModel();
1475 eleazar 230
                $viewModel->setTemplate('leaders-linked/recruitment-and-selection-candidates/index.phtml');
10131 stevensc 231
                $viewModel->setVariables([
232
                    'form' => $form,
233
                    'vacancies' => $vacancies,
234
                ]);
1468 eleazar 235
 
236
                return $viewModel;
237
            }
238
        } else {
239
            return new JsonModel([
240
                'success' => false,
241
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
242
            ]);
243
            ;
244
        }
245
    }
246
 
1485 eleazar 247
    public function addAction()
248
    {
249
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
250
        $currentCompany     = $currentUserPlugin->getCompany();
251
        $currentUser        = $currentUserPlugin->getUser();
252
 
253
        $request    = $this->getRequest();
254
 
1515 eleazar 255
        $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
256
 
1485 eleazar 257
        if($request->isPost()) {
1513 eleazar 258
            $form = new  RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
1516 eleazar 259
            $dataPost = array_merge(
260
                $request->getPost()->toArray(),
261
                $request->getFiles()->toArray(),
262
                ['form_uuid' => $vacancy_uuid],
263
            );
1485 eleazar 264
 
265
            $form->setData($dataPost);
266
 
267
            if($form->isValid()) {
268
                $dataPost = (array) $form->getData();
269
 
1592 eleazar 270
                $files = $this->getRequest()->getFiles()->toArray();
271
 
1485 eleazar 272
                $hydrator = new ObjectPropertyHydrator();
273
                $candidate = new RecruitmentSelectionCandidate();
274
                $hydrator->hydrate($dataPost, $candidate);
275
 
276
                $candidate->company_id = $currentCompany->id;
1586 eleazar 277
                $candidate->file = null;
1520 eleazar 278
 
279
                $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
280
                $vacancy = $vacancyMapper->fetchOneByUuid($vacancy_uuid);
281
 
2680 eleazar 282
                $candidate->vacancy_id = $vacancy->id;
1494 eleazar 283
                $candidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1518 eleazar 284
 
1534 eleazar 285
                if($candidateMapper->insert($candidate)) {
1593 eleazar 286
                     $candidate = $candidateMapper->fetchOne($candidate->id);
1485 eleazar 287
 
288
                    //leaderslinked.fullpath.recruitment_selection/uuid vacante/uuid candidato
289
 
8581 eleazar 290
                     $target_path = $this->config['leaderslinked.fullpath.recruitment_selection'].$vacancy->uuid.DIRECTORY_SEPARATOR.$candidate->uuid;
1582 eleazar 291
                     if(!file_exists($target_path)) {
292
                         mkdir($target_path, 0755, true);
293
                     }
294
                    $files = $this->getRequest()->getFiles()->toArray();
295
                     if(isset($files['file']) && empty($files['file']['error'])) {
296
                         $tmp_filename  = $files['file']['tmp_name'];
1592 eleazar 297
                         $original_filename  = trim(strtolower($files['file']['name']));
1582 eleazar 298
                        try {
1592 eleazar 299
                            $parts = explode('.', $original_filename);
300
                            $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
301
 
302
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
303
                            if(move_uploaded_file($tmp_filename, $full_filename)) {
1582 eleazar 304
                                 $candidate->file = $filename;
305
                                 $candidateMapper->update($candidate);
306
                             }
307
                         } catch(\Throwable $e) {
308
                             error_log($e->getTraceAsString());
309
                         }
310
                     }
1518 eleazar 311
 
1588 eleazar 312
                    $this->logger->info('Se agrego el candidato ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1485 eleazar 313
 
314
                    $data = [
315
                        'success'   => true,
316
                        'data'   => 'LABEL_RECORD_ADDED'
317
                    ];
318
                } else {
319
                    $data = [
320
                        'success'   => false,
1494 eleazar 321
                        'data'      => $candidateMapper->getError()
1485 eleazar 322
                    ];
323
 
324
                }
325
 
326
                return new JsonModel($data);
327
 
328
            } else {
329
                $messages = [];
330
                $form_messages = (array) $form->getMessages();
331
                foreach($form_messages  as $fieldname => $field_messages)
332
                {
333
 
334
                    $messages[$fieldname] = array_values($field_messages);
335
                }
336
 
337
            }
338
 
339
        } else {
340
            $data = [
341
                'success' => false,
342
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
343
            ];
344
 
345
            return new JsonModel($data);
346
        }
347
 
348
        return new JsonModel($data);
349
    }
1614 eleazar 350
 
351
    public function editAction() {
352
        $request = $this->getRequest();
353
        $currentUserPlugin = $this->plugin('currentUserPlugin');
354
        $currentCompany = $currentUserPlugin->getCompany();
355
        $currentUser = $currentUserPlugin->getUser();
356
 
357
        $request = $this->getRequest();
1623 eleazar 358
        $id = $this->params()->fromRoute('id');
1614 eleazar 359
 
1625 eleazar 360
        if (!$id) {
1614 eleazar 361
            $data = [
362
                'success' => false,
363
                'data' => 'ERROR_INVALID_PARAMETER'
364
            ];
365
 
366
            return new JsonModel($data);
367
        }
368
 
369
        $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
1625 eleazar 370
        $candidate = $recruitmentSelectionCandidateMapper->fetchOneByUuid($id);
371
 
372
        if (!$candidate) {
1614 eleazar 373
            $data = [
374
                'success' => false,
375
                'data' => 'ERROR_RECORD_NOT_FOUND'
376
            ];
377
 
378
            return new JsonModel($data);
379
        }
380
 
1625 eleazar 381
        if ($candidate->company_id != $currentCompany->id) {
1614 eleazar 382
            return new JsonModel([
383
                'success' => false,
384
                'data' => 'ERROR_UNAUTHORIZED'
385
            ]);
386
        }
8540 efrain 387
 
388
        $vacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
389
        $vacancy = $vacancyMapper->fetchOne($candidate->vacancy_id);
390
 
1614 eleazar 391
 
8540 efrain 392
 
1614 eleazar 393
        if ($request->isPost()) {
1626 eleazar 394
            $vacancy_uuid = $this->params()->fromRoute('vacancy_uuid');
1614 eleazar 395
            $form = new RecruitmentSelectionCandidateFormForm($this->adapter, $currentCompany->id);
396
            $dataPost = $request->getPost()->toArray();
3879 eleazar 397
            $dataPost['status'] = isset($dataPost['status']) ? $dataPost['status'] : RecruitmentSelectionCandidate::STATUS_REJECTED;
1626 eleazar 398
            $dataPost['form_uuid'] = $vacancy_uuid;
1614 eleazar 399
 
400
            $form->setData($dataPost);
401
 
402
            if ($form->isValid()) {
403
                $dataPost = (array) $form->getData();
404
 
405
                $hydrator = new ObjectPropertyHydrator();
406
                $hydrator->hydrate($dataPost, $candidate);
407
 
1625 eleazar 408
                if($recruitmentSelectionCandidateMapper->update($candidate)) {
409
                    $candidate = $recruitmentSelectionCandidateMapper->fetchOne($candidate->id);
1623 eleazar 410
 
411
                   //leaderslinked.fullpath.recruitment_selection/uuid vacante/uuid candidato
412
 
8581 eleazar 413
                    $target_path = $this->config['leaderslinked.fullpath.recruitment_selection'].$vacancy_uuid.DIRECTORY_SEPARATOR.$candidate->uuid;
1623 eleazar 414
                    if(!file_exists($target_path)) {
415
                        mkdir($target_path, 0755, true);
416
                    }
1625 eleazar 417
 
418
                    $files = $this->getRequest()->getFiles()->toArray();
419
 
1623 eleazar 420
                    if(isset($files['file']) && empty($files['file']['error'])) {
421
                        $tmp_filename  = $files['file']['tmp_name'];
422
                        $original_filename  = trim(strtolower($files['file']['name']));
1625 eleazar 423
 
424
                        try {
425
                            $parts = explode('.', $original_filename);
426
                            $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
427
 
428
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
429
                            if(move_uploaded_file($tmp_filename, $full_filename)) {
1623 eleazar 430
                                $candidate->file = $filename;
1625 eleazar 431
                                $recruitmentSelectionCandidateMapper->update($candidate);
1623 eleazar 432
                            }
433
                        } catch(\Throwable $e) {
434
                            error_log($e->getTraceAsString());
435
                        }
436
                    }
437
 
438
                   $this->logger->info('Se agrego el candidato ' . $candidate->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
439
 
440
                   $data = [
441
                       'success'   => true,
1628 eleazar 442
                       'data'   => 'LABEL_RECORD_UPDATED'
1623 eleazar 443
                   ];
444
               } else {
445
                   $data = [
446
                       'success'   => false,
1625 eleazar 447
                       'data'      => $recruitmentSelectionCandidateMapper->getError()
1623 eleazar 448
                   ];
449
 
450
               }
451
 
1614 eleazar 452
                return new JsonModel($data);
453
            } else {
454
                $messages = [];
455
                $form_messages = (array) $form->getMessages();
456
                foreach ($form_messages as $fieldname => $field_messages) {
457
                    $messages[$fieldname] = array_values($field_messages);
458
                }
459
 
460
                return new JsonModel([
461
                    'success' => false,
462
                    'data' => $messages
463
                ]);
464
            }
465
        } else if ($request->isGet()) {
8539 efrain 466
 
1614 eleazar 467
            $hydrator = new ObjectPropertyHydrator();
468
 
469
            $data = [
470
                'success' => true,
471
                'data' => [
472
                    'id' => $candidate->uuid,
1660 eleazar 473
                    'user_id' => $candidate->user_id,
1614 eleazar 474
                    'first_name' => $candidate->first_name,
475
                    'last_name' => $candidate->last_name,
476
                    'email' => $candidate->email,
8540 efrain 477
                    'file' => $this->url()->fromRoute('storage', ['type' => 'recruitment-selection', 'code'=> $vacancy->uuid, 'code2'=> $candidate->uuid, 'filename' => $candidate->file]),
1658 eleazar 478
                    'evaluation' => $candidate->evaluation,
15120 stevensc 479
                    'coment' => $candidate->coment,
1614 eleazar 480
                    'status' => $candidate->status,
481
                ]
482
            ];
483
 
484
            return new JsonModel($data);
485
        } else {
486
            $data = [
487
                'success' => false,
1619 eleazar 488
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1614 eleazar 489
            ];
490
 
491
            return new JsonModel($data);
492
        }
493
 
494
        return new JsonModel($data);
495
    }
496
 
497
    public function deleteAction() {
498
        $request = $this->getRequest();
499
        $currentUserPlugin = $this->plugin('currentUserPlugin');
500
        $currentCompany = $currentUserPlugin->getCompany();
501
        $currentUser = $currentUserPlugin->getUser();
502
 
503
        $request = $this->getRequest();
504
        $uuid = $this->params()->fromRoute('id');
505
 
506
        if (!$uuid) {
507
            $data = [
508
                'success' => false,
509
                'data' => 'ERROR_INVALID_PARAMETER'
510
            ];
511
 
512
            return new JsonModel($data);
513
        }
514
 
515
        $recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
516
        $candidateMapper = $recruitmentSelectionCandidateMapper->fetchOneByUuid($uuid);
517
        if (!$candidateMapper) {
518
            $data = [
519
                'success' => false,
520
                'data' => 'ERROR_RECORD_NOT_FOUND'
521
            ];
522
 
523
            return new JsonModel($data);
524
        }
525
 
526
        if ($candidateMapper->company_id != $currentCompany->id) {
527
            return new JsonModel([
528
                'success' => false,
529
                'data' => 'ERROR_UNAUTHORIZED'
530
            ]);
531
        }
532
 
533
        if ($request->isPost()) {
534
 
535
 
536
            $result = $recruitmentSelectionCandidateMapper->delete($candidateMapper->id);
537
            if ($result) {
1615 eleazar 538
                $this->logger->info('Se borro el candidato ' . $candidateMapper->first_name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1614 eleazar 539
 
540
                $data = [
541
                    'success' => true,
542
                    'data' => 'LABEL_RECORD_DELETED'
543
                ];
544
            } else {
545
 
546
                $data = [
547
                    'success' => false,
548
                    'data' => $recruitmentSelectionCandidateMapper->getError()
549
                ];
550
 
551
                return new JsonModel($data);
552
            }
553
        } else {
554
            $data = [
555
                'success' => false,
556
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
557
            ];
558
 
559
            return new JsonModel($data);
560
        }
561
 
562
        return new JsonModel($data);
563
    }
564
 
1632 eleazar 565
    public function emailAction() {
1630 eleazar 566
        $request = $this->getRequest();
567
        $currentUserPlugin = $this->plugin('currentUserPlugin');
568
        $currentCompany = $currentUserPlugin->getCompany();
569
        $currentUser = $currentUserPlugin->getUser();
1640 eleazar 570
 
571
        $email = $request->getQuery('email');
1643 eleazar 572
 
573
        if(!$email){
574
            $data = [
575
                'success' => false,
576
                'data' => 'ERROR_INVALID_PARAMETER'
577
            ];
578
 
579
            return new JsonModel($data);
580
        }
581
 
582
        $userMapper = UserMapper::getInstance($this->adapter);
583
        $user = $userMapper->fetchOneByEmail($email);
584
 
585
        if (!$user) {
586
            return new JsonModel([
587
                'success' => false,
588
                'data' => 'ERROR_USER_NOT_FOUND',
589
            ]);
1644 eleazar 590
        } else if($request->isGet()){
591
            $data = [
592
                'success' => true,
593
                'data' => [
1663 eleazar 594
                    'user_id' => $user->id,
1644 eleazar 595
                    'first_name' => $user->first_name,
596
                    'last_name' => $user->last_name,
597
 
598
                ]
599
            ];
600
            return new JsonModel($data);
601
 
602
        }else {
603
            $data = [
1643 eleazar 604
                'success' => false,
1644 eleazar 605
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
606
            ];
607
 
608
            return new JsonModel($data);
1643 eleazar 609
        }
1630 eleazar 610
    }
1468 eleazar 611
}