Conditions | 5 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function update(string $id): ?string |
||
30 | { |
||
31 | if (!Any::isInt($id) || $id < 1) { |
||
32 | throw new SyntaxException('Wrong id syntax'); |
||
33 | } |
||
34 | $user = UserRecord::findOrNew($id); |
||
35 | // generate model data based on user object |
||
36 | $model = new FormUserUpdate($user); |
||
37 | |||
38 | // check is form is sended |
||
39 | if ($model->send()) { |
||
40 | if ($model->validate()) { // check validation |
||
41 | $model->save(); |
||
42 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
||
43 | } else { |
||
44 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | // render viewer |
||
49 | return $this->view->render('user_update', [ |
||
50 | 'model' => $model |
||
51 | ]); |
||
52 | } |
||
53 | } |
||
54 |