Conditions | 5 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function display($type, $id) |
||
29 | { |
||
30 | /** @var CommentPost|CommentAnswer|null $record */ |
||
31 | $record = null; |
||
32 | switch ($type) { |
||
33 | case self::TYPE_COMMENT: |
||
|
|||
34 | $record = CommentPost::find($id); |
||
35 | break; |
||
36 | case self::TYPE_ANSWER: |
||
37 | $record = CommentAnswer::find($id); |
||
38 | break; |
||
39 | } |
||
40 | |||
41 | if (!$record) { |
||
42 | throw new NotFoundException('No comments found'); |
||
43 | } |
||
44 | |||
45 | $record->moderate = !$record->moderate; |
||
46 | $record->save(); |
||
47 | |||
48 | if ($type === self::TYPE_ANSWER) { |
||
49 | $this->response->redirect('comments/answerlist'); |
||
50 | } |
||
51 | |||
52 | $this->response->redirect('comments/index'); |
||
53 | } |
||
55 |