|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Magium\Configuration\View; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Http\Message\MessageInterface; |
|
6
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
7
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
8
|
|
|
|
|
9
|
|
|
class ViewConfiguration |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
protected $request; |
|
13
|
|
|
protected $response; |
|
14
|
|
|
protected $layoutFile; |
|
15
|
|
|
protected $viewDirectory; |
|
16
|
|
|
protected $viewFile; |
|
17
|
|
|
protected $jqueryUrl; |
|
18
|
|
|
protected $provideWrapperHtml; |
|
19
|
|
|
protected $bootstrapJsUrl; |
|
20
|
|
|
protected $bootstrapCssUrl; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* ViewConfiguration constructor. |
|
24
|
|
|
* @param ServerRequestInterface $request |
|
25
|
|
|
* @param MessageInterface $response |
|
26
|
|
|
* @param string $viewDirectory |
|
27
|
|
|
* @param string $layoutFile |
|
28
|
|
|
* @param string $viewFile |
|
29
|
|
|
* @param boolean $provideWrapperHtml |
|
30
|
|
|
* @param boolean $provideJqueryUrl |
|
|
|
|
|
|
31
|
|
|
* @throws InvalidViewConfigurationException |
|
32
|
|
|
*/ |
|
33
|
23 |
|
public function __construct( |
|
34
|
|
|
ServerRequestInterface $request, |
|
35
|
|
|
MessageInterface $response, |
|
36
|
|
|
$viewDirectory = __DIR__ . '/views' , |
|
37
|
|
|
$layoutFile = 'layout.phtml', |
|
38
|
|
|
$viewFile = 'view.phtml', |
|
39
|
|
|
$provideWrapperHtml = true, |
|
40
|
|
|
$jqueryUrl = 'https://code.jquery.com/jquery-3.2.1.min.js', |
|
41
|
|
|
$bootstrapJsUrl = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', |
|
42
|
|
|
$bootstrapCssUrl = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' |
|
43
|
|
|
) |
|
44
|
|
|
{ |
|
45
|
23 |
|
$this->setRequest($request); |
|
46
|
23 |
|
$this->setResponse($response); |
|
47
|
23 |
|
$this->setViewDirectory($viewDirectory); |
|
48
|
22 |
|
$this->setLayoutFile($layoutFile); |
|
49
|
21 |
|
$this->setViewFile($viewFile); |
|
50
|
20 |
|
$this->setProvideWrapperHtml($provideWrapperHtml); |
|
51
|
20 |
|
$this->setJqueryUrl($jqueryUrl); |
|
52
|
20 |
|
$this->setBootstrapJsUrl($bootstrapJsUrl); |
|
53
|
20 |
|
$this->setBootstrapCssUrl($bootstrapCssUrl); |
|
54
|
20 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return mixed |
|
58
|
|
|
*/ |
|
59
|
9 |
|
public function getBootstrapCssUrl() |
|
60
|
|
|
{ |
|
61
|
9 |
|
return $this->bootstrapCssUrl; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param mixed $bootstrapCssUrl |
|
66
|
|
|
*/ |
|
67
|
20 |
|
public function setBootstrapCssUrl($bootstrapCssUrl) |
|
68
|
|
|
{ |
|
69
|
20 |
|
$this->bootstrapCssUrl = $bootstrapCssUrl; |
|
70
|
20 |
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return mixed |
|
74
|
|
|
*/ |
|
75
|
9 |
|
public function getBootstrapJsUrl() |
|
76
|
|
|
{ |
|
77
|
9 |
|
return $this->bootstrapJsUrl; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param mixed $bootstrapJsUrl |
|
82
|
|
|
*/ |
|
83
|
20 |
|
public function setBootstrapJsUrl($bootstrapJsUrl) |
|
84
|
|
|
{ |
|
85
|
20 |
|
$this->bootstrapJsUrl = $bootstrapJsUrl; |
|
86
|
20 |
|
} |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return mixed |
|
92
|
|
|
*/ |
|
93
|
9 |
|
public function getProvideWrapperHtml() |
|
94
|
|
|
{ |
|
95
|
9 |
|
return $this->provideWrapperHtml; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param mixed $provideWrapperHtml |
|
100
|
|
|
*/ |
|
101
|
20 |
|
public function setProvideWrapperHtml($provideWrapperHtml) |
|
102
|
|
|
{ |
|
103
|
20 |
|
$this->provideWrapperHtml = $provideWrapperHtml; |
|
104
|
20 |
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return ServerRequestInterface |
|
108
|
|
|
*/ |
|
109
|
1 |
|
public function getRequest() |
|
110
|
|
|
{ |
|
111
|
1 |
|
return $this->request; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param ServerRequestInterface $request |
|
116
|
|
|
*/ |
|
117
|
23 |
|
public function setRequest(ServerRequestInterface $request) |
|
118
|
|
|
{ |
|
119
|
23 |
|
$this->request = $request; |
|
120
|
23 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return ResponseInterface |
|
124
|
|
|
*/ |
|
125
|
1 |
|
public function getResponse() |
|
126
|
|
|
{ |
|
127
|
1 |
|
return $this->response; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param MessageInterface $response |
|
132
|
|
|
*/ |
|
133
|
23 |
|
public function setResponse(MessageInterface $response) |
|
134
|
|
|
{ |
|
135
|
23 |
|
$this->response = $response; |
|
136
|
23 |
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return string |
|
140
|
|
|
*/ |
|
141
|
9 |
|
public function getLayoutFile() |
|
142
|
|
|
{ |
|
143
|
9 |
|
return $this->layoutFile; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param string $layoutFile |
|
148
|
|
|
* @throws InvalidViewConfigurationException |
|
149
|
|
|
*/ |
|
150
|
22 |
View Code Duplication |
public function setLayoutFile($layoutFile) |
|
151
|
|
|
{ |
|
152
|
22 |
|
$this->layoutFile = realpath($this->getViewDirectory() . DIRECTORY_SEPARATOR . $layoutFile); |
|
153
|
22 |
|
if (!is_file($this->layoutFile)) { |
|
154
|
1 |
|
throw new InvalidViewConfigurationException('Could not resolve base layout file: ' . $layoutFile); |
|
155
|
|
|
} |
|
156
|
21 |
|
$this->layoutFile = basename($this->layoutFile); |
|
157
|
21 |
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* @return string |
|
161
|
|
|
*/ |
|
162
|
22 |
|
public function getViewDirectory() |
|
163
|
|
|
{ |
|
164
|
22 |
|
return $this->viewDirectory; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @param string $viewDirectory |
|
169
|
|
|
* @throws InvalidViewConfigurationException |
|
170
|
|
|
*/ |
|
171
|
23 |
|
public function setViewDirectory($viewDirectory) |
|
172
|
|
|
{ |
|
173
|
23 |
|
$this->viewDirectory = realpath($viewDirectory); |
|
174
|
23 |
|
if (!is_dir($this->viewDirectory)) { |
|
175
|
1 |
|
throw new InvalidViewConfigurationException('Could not resolve base view directory: ' . $viewDirectory); |
|
176
|
|
|
} |
|
177
|
22 |
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return string |
|
181
|
|
|
*/ |
|
182
|
1 |
|
public function getViewFile() |
|
183
|
|
|
{ |
|
184
|
1 |
|
return $this->viewFile; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @param string $viewFile |
|
189
|
|
|
* @throws InvalidViewConfigurationException |
|
190
|
|
|
*/ |
|
191
|
21 |
View Code Duplication |
public function setViewFile($viewFile) |
|
192
|
|
|
{ |
|
193
|
21 |
|
$this->viewFile = realpath($this->getViewDirectory() . DIRECTORY_SEPARATOR . $viewFile); |
|
194
|
21 |
|
if (!is_file($this->viewFile)) { |
|
195
|
1 |
|
throw new InvalidViewConfigurationException('Could not resolve base file file: ' . $viewFile); |
|
196
|
|
|
} |
|
197
|
20 |
|
$this->viewFile = basename($this->viewFile); |
|
198
|
20 |
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @return mixed |
|
202
|
|
|
*/ |
|
203
|
9 |
|
public function getJqueryUrl() |
|
204
|
|
|
{ |
|
205
|
9 |
|
return $this->jqueryUrl; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* @param mixed $jqueryUrl |
|
210
|
|
|
*/ |
|
211
|
20 |
|
public function setJqueryUrl($jqueryUrl) |
|
212
|
|
|
{ |
|
213
|
20 |
|
$this->jqueryUrl = $jqueryUrl; |
|
214
|
20 |
|
} |
|
215
|
|
|
|
|
216
|
|
|
|
|
217
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
} |
|
220
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.