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