Conditions | 6 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function categoryDelete(string $id): ?string |
||
30 | { |
||
31 | // check id |
||
32 | if (!Any::isInt($id) || $id < 2) { |
||
33 | throw new ForbiddenException(); |
||
34 | } |
||
35 | |||
36 | // get object relation |
||
37 | $record = ContentCategory::find($id); |
||
38 | if (!$record) { |
||
39 | throw new ForbiddenException(); |
||
40 | } |
||
41 | |||
42 | // init model with object relation |
||
43 | $model = new FormCategoryDelete($record); |
||
44 | |||
45 | // check if delete is submited |
||
46 | if ($model->send() && $model->validate()) { |
||
47 | $model->make(); |
||
48 | App::$Session->getFlashBag()->add('success', __('Category is successful removed')); |
||
49 | $this->response->redirect('content/categories'); |
||
50 | } |
||
51 | |||
52 | // draw view |
||
53 | return $this->view->render('category_delete', [ |
||
54 | 'model' => $model |
||
55 | ]); |
||
56 | } |
||
57 | } |
||
58 |