| Conditions | 6 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function restore(string $id): ?string |
||
| 31 | { |
||
| 32 | if (!Any::isInt($id) || $id < 1) { |
||
| 33 | throw new NotFoundException(); |
||
| 34 | } |
||
| 35 | |||
| 36 | // get removed object |
||
| 37 | $record = ContentEntity::onlyTrashed()->find($id); |
||
| 38 | if (!$record) { |
||
| 39 | throw new NotFoundException(); |
||
| 40 | } |
||
| 41 | |||
| 42 | // init model |
||
| 43 | $model = new FormContentRestore($record); |
||
| 44 | // check if action is send |
||
| 45 | if ($model->send() && $model->validate()) { |
||
| 46 | $model->make(); |
||
| 47 | App::$Session->getFlashBag()->add('success', __('Content are successful recovered')); |
||
| 48 | $this->response->redirect('content/index'); |
||
| 49 | } |
||
| 50 | |||
| 51 | // draw response |
||
| 52 | return $this->view->render('content/content_restore', [ |
||
| 53 | 'model' => $model |
||
| 54 | ]); |
||
| 57 |