1 | <?php |
||
13 | class CommentModel implements ConfigureInterface, InjectionAwareInterface |
||
14 | { |
||
15 | use ConfigureTrait; |
||
16 | use InjectionAwareTrait; |
||
17 | |||
18 | |||
19 | /** |
||
20 | * @var array $session inject a reference to the session. |
||
21 | */ |
||
22 | private $session; |
||
23 | |||
24 | |||
25 | |||
26 | /** |
||
27 | * @var string $key to use when storing in session. |
||
28 | */ |
||
29 | const KEY = "comment"; |
||
30 | |||
31 | |||
32 | |||
33 | /** |
||
34 | * Inject dependency to $session.. |
||
35 | * |
||
36 | * @param array $session object representing session. |
||
37 | * |
||
38 | * @return self |
||
39 | */ |
||
40 | 3 | public function injectSession($session) |
|
45 | |||
46 | |||
47 | /** |
||
48 | * View all posts |
||
49 | * |
||
50 | * @return void |
||
51 | */ |
||
52 | 1 | public function viewAll() |
|
58 | |||
59 | /** |
||
60 | * Show one post |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | 1 | public function showOnePost($id) |
|
70 | |||
71 | /** |
||
72 | * Edit post |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | 1 | public function editPost($id) |
|
77 | { |
||
78 | 1 | $sql = "SELECT * FROM ramverk1_comment where id = ?"; |
|
79 | |||
80 | 1 | return $this->di->get("database")->executeFetch($sql, [$id]); |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * Delete post |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | public function removePost($id) |
||
94 | } |
||
95 |