1 | <?php |
||
8 | class CommentsController implements InjectionAwareInterface |
||
9 | { |
||
10 | use InjectionAwareTrait; |
||
11 | |||
12 | private $db; |
||
13 | private $session; |
||
14 | private $response; |
||
15 | |||
16 | 1 | public function init($database) |
|
21 | |||
22 | 1 | public function inject($session) |
|
23 | { |
||
24 | 1 | $this->session = $session; |
|
25 | 1 | return $this; |
|
26 | } |
||
27 | |||
28 | 1 | public function add() |
|
29 | { |
||
30 | 1 | $user = $this->session->get("user"); |
|
31 | 1 | $this->di->get("comments")->addComment($_POST, $this->db, $user); |
|
32 | 1 | $this->response->redirect("comments"); |
|
33 | } |
||
34 | |||
35 | 1 | public function delete() |
|
36 | { |
||
37 | 1 | $this->di->get("comments")->deleteComment($_GET['id'], $this->db); |
|
38 | 1 | $this->response->redirect("comments"); |
|
39 | } |
||
40 | |||
41 | 1 | public function edit() |
|
42 | { |
||
43 | 1 | $this->di->get("comments")->editComment($_POST['id'], $_POST['comment'], $this->db); |
|
44 | 1 | $this->response->redirect("comments"); |
|
45 | } |
||
46 | |||
47 | 1 | public function get($id) |
|
51 | |||
52 | 1 | public function addCommentSection() |
|
59 | |||
60 | public function renderMain() |
||
67 | |||
68 | public function renderEdit() |
||
75 | } |
||
76 |