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