1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Anax\Page; |
4
|
|
|
|
5
|
|
|
use \Anax\DI\InjectionAwareInterface; |
6
|
|
|
use \Anax\DI\InjectionAwareTrait; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* A default page rendering class. |
10
|
|
|
*/ |
11
|
|
|
class DevelopController implements InjectionAwareInterface |
12
|
|
|
{ |
13
|
|
|
use InjectionAwareTrait; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string $namespace A namespace to prepend each template file. |
19
|
|
|
*/ |
20
|
|
|
private $namespace = "anax/v1/dev"; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Render a page showing a menu with links to all dev pages. |
26
|
|
|
* |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
View Code Duplication |
public function index() |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$this->di->get("view")->add("{$this->namespace}/index"); |
32
|
|
|
$this->di->get("page")->render([ |
33
|
|
|
"title" => "Anax development utilitites", |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Render a page displaying information on services loaded in $di. |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
public function di() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$this->di->get("view")->add("{$this->namespace}/di"); |
47
|
|
|
$this->di->get("page")->render([ |
48
|
|
|
"title" => "Show loaded services in \$di", |
49
|
|
|
]); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Render a page displaying information on the current request. |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
View Code Duplication |
public function request() |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$this->di->get("view")->add("{$this->namespace}/request"); |
62
|
|
|
$this->di->get("page")->render([ |
63
|
|
|
"title" => "Details on current request", |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Render a page displaying information on routes loaded in framework. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
View Code Duplication |
public function route() |
|
|
|
|
75
|
|
|
{ |
76
|
|
|
$this->di->get("view")->add("{$this->namespace}/route"); |
77
|
|
|
$this->di->get("page")->render([ |
78
|
|
|
"title" => "Show loaded routes", |
79
|
|
|
]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Render a page displaying session data. |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
View Code Duplication |
public function session() |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
$this->di->get("view")->add("{$this->namespace}/session"); |
92
|
|
|
$this->di->get("page")->render([ |
93
|
|
|
"title" => "Show session data", |
94
|
|
|
]); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Render a page displaying details on view helpers. |
101
|
|
|
* |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
View Code Duplication |
public function view() |
|
|
|
|
105
|
|
|
{ |
106
|
|
|
$this->di->get("view")->add("{$this->namespace}/view"); |
107
|
|
|
$this->di->get("page")->render([ |
108
|
|
|
"title" => "View helpers", |
109
|
|
|
]); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.