Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function display(string $id): void |
||
27 | { |
||
28 | $status = (bool)$this->request->query->get('status', 0); |
||
29 | $content = \Apps\ActiveRecord\Content::find($id); |
||
30 | if (!$content) { |
||
31 | throw new NotFoundException(__('Content {%id%} are not exist', ['id' => $id])); |
||
32 | } |
||
33 | // make update query if status is different than required |
||
34 | if ((bool)$content->display !== $status) { |
||
35 | $content->display = $status; |
||
36 | $content->save(); |
||
37 | } |
||
38 | |||
39 | $this->response->redirect('content/index'); |
||
40 | } |
||
41 | } |