|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Forum\Comment; |
|
4
|
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
|
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
|
7
|
|
|
use Forum\Comment\HTMLForm\CreateForm; |
|
8
|
|
|
use Forum\Answer\Answer; |
|
9
|
|
|
use Forum\Question\Question; |
|
10
|
|
|
|
|
11
|
|
|
// use Anax\Route\Exception\ForbiddenException; |
|
12
|
|
|
// use Anax\Route\Exception\NotFoundException; |
|
13
|
|
|
// use Anax\Route\Exception\InternalErrorException; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* A sample controller to show how a controller class can be implemented. |
|
17
|
|
|
*/ |
|
18
|
|
|
class CommentController implements ContainerInjectableInterface |
|
19
|
|
|
{ |
|
20
|
|
|
use ContainerInjectableTrait; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var $data description |
|
25
|
|
|
*/ |
|
26
|
|
|
//private $data; |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
// /** |
|
30
|
|
|
// * The initialize method is optional and will always be called before the |
|
31
|
|
|
// * target method/action. This is a convienient method where you could |
|
32
|
|
|
// * setup internal properties that are commonly used by several methods. |
|
33
|
|
|
// * |
|
34
|
|
|
// * @return void |
|
35
|
|
|
// */ |
|
36
|
|
|
// public function initialize() : void |
|
37
|
|
|
// { |
|
38
|
|
|
// ; |
|
39
|
|
|
// } |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Description. |
|
44
|
|
|
* |
|
45
|
|
|
* @param datatype $variable Description |
|
|
|
|
|
|
46
|
|
|
* |
|
47
|
|
|
* @return object as a response object |
|
48
|
|
|
* @throws Exception |
|
49
|
|
|
* |
|
50
|
|
|
*/ |
|
51
|
|
|
public function indexActionGet(): object |
|
52
|
|
|
{ |
|
53
|
|
|
$user_id = $this->di->get("session")->get("user_id"); |
|
54
|
|
|
var_dump($user_id); |
|
|
|
|
|
|
55
|
|
|
if (!$user_id) { |
|
56
|
|
|
$this->di->get("response")->redirect("user/login"); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
View Code Duplication |
public function questionAction(int $questionId): object |
|
|
|
|
|
|
61
|
|
|
{ |
|
62
|
|
|
$page = $this->di->get("page"); |
|
63
|
|
|
$form = new CreateForm($this->di, $questionId, ""); |
|
64
|
|
|
$question = new Question(); |
|
65
|
|
|
$question->setDb($this->di->get("dbqb")); |
|
66
|
|
|
$form->check(); |
|
67
|
|
|
$text = $question->findById($questionId)->question; |
|
68
|
|
|
$data = [ |
|
69
|
|
|
"form" => $form->getHTML(), |
|
70
|
|
|
"text" => $text, |
|
71
|
|
|
"title" => "create comment", |
|
72
|
|
|
]; |
|
73
|
|
|
$page->add("forum/create_comment", $data); |
|
74
|
|
|
return $page->render($data); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
View Code Duplication |
public function answerAction(int $answerId): object |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
$page = $this->di->get("page"); |
|
81
|
|
|
$form = new CreateForm($this->di, "", $answerId); |
|
82
|
|
|
$answer = new Answer(); |
|
83
|
|
|
$answer->setDb($this->di->get("dbqb")); |
|
84
|
|
|
$form->check(); |
|
85
|
|
|
$text = $answer->findById($answerId)->answer; |
|
86
|
|
|
$data = [ |
|
87
|
|
|
"form" => $form->getHTML(), |
|
88
|
|
|
"text" => $text, |
|
89
|
|
|
"title" => "create comment", |
|
90
|
|
|
]; |
|
91
|
|
|
$page->add("forum/create_comment", $data); |
|
92
|
|
|
return $page->render($data); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.