Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function update(?string $id = null): ?string |
||
28 | { |
||
29 | // get item with trashed objects |
||
30 | $record = ContentEntity::withTrashed()->findOrNew($id); |
||
31 | $isNew = $record->id === null; |
||
32 | |||
33 | // init model |
||
34 | $model = new FormContentUpdate($record); |
||
35 | |||
36 | // check if model is submit |
||
37 | if ($model->send() && $model->validate()) { |
||
38 | $model->save(); |
||
39 | if ($isNew === true) { |
||
40 | $this->response->redirect('content/index'); |
||
41 | } |
||
42 | App::$Session->getFlashBag()->add('success', __('Content is successful updated')); |
||
43 | } |
||
44 | |||
45 | // draw response |
||
46 | return $this->view->render('content_update', [ |
||
47 | 'model' => $model |
||
48 | ]); |
||
51 |