1 | <?php |
||
9 | class View |
||
10 | { |
||
11 | /** |
||
12 | * Active layout for view |
||
13 | * |
||
14 | * @var string|bool |
||
15 | */ |
||
16 | protected $layout; |
||
17 | |||
18 | /** |
||
19 | * Active module for view |
||
20 | * |
||
21 | * @var string|bool |
||
22 | */ |
||
23 | protected $module = false; |
||
24 | |||
25 | /** |
||
26 | * Rendered view content |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $view = false; |
||
31 | |||
32 | /** |
||
33 | * Data object for view |
||
34 | * |
||
35 | * @var object |
||
36 | */ |
||
37 | protected $properties; |
||
38 | |||
39 | /** |
||
40 | * \Zewa\Config reference |
||
41 | * |
||
42 | * @var Config |
||
43 | */ |
||
44 | protected $configuration; |
||
45 | |||
46 | /** |
||
47 | * \Zewa\Router reference |
||
48 | * |
||
49 | * @var Router |
||
50 | */ |
||
51 | protected $router; |
||
52 | |||
53 | /** |
||
54 | * \Zewa\Router reference |
||
55 | * |
||
56 | * @var Router |
||
57 | */ |
||
58 | protected $request; |
||
59 | |||
60 | /** |
||
61 | * @var array |
||
62 | */ |
||
63 | private $queuedJS = []; |
||
64 | |||
65 | /** |
||
66 | * @var array |
||
67 | */ |
||
68 | private $queuedCSS = []; |
||
69 | |||
70 | /** |
||
71 | * Load up some basic configuration settings. |
||
72 | */ |
||
73 | public function __construct(Config $config, Router $router, Request $request) |
||
79 | |||
80 | /** |
||
81 | * Returns base URL for app |
||
82 | * @return string |
||
83 | */ |
||
84 | private function baseURL($path = '') |
||
88 | |||
89 | /** |
||
90 | * Returns the current request URL |
||
91 | * @return string |
||
92 | */ |
||
93 | private function currentURL($params = false) |
||
97 | |||
98 | /** |
||
99 | * Returns uri string |
||
100 | * @return string |
||
101 | */ |
||
102 | private function currentURI() |
||
106 | |||
107 | /* |
||
108 | * @todo create method for returning |
||
109 | * a valid json string with header.. |
||
110 | * view shouldn't set header logic, |
||
111 | * and the framework doesn't care what returns the string |
||
112 | * ..but view should handle the json_encode... |
||
113 | * seems overkill to call header() with returning a $view->json; |
||
114 | * thoughts?*/ |
||
115 | |||
116 | /** |
||
117 | * Loads a view |
||
118 | * |
||
119 | * @access public |
||
120 | * @param string|bool $view view to load |
||
121 | * @param string|bool $layout |
||
122 | * @return string |
||
123 | */ |
||
124 | public function render($view = false, $layout = false) |
||
152 | |||
153 | /** |
||
154 | * formats and prepares view for inclusion |
||
155 | * @param $viewName |
||
156 | * @return string |
||
157 | * @throws Exception\LookupException |
||
158 | */ |
||
159 | private function prepareView($viewName) |
||
182 | |||
183 | public function setView($viewName, $layout = false) |
||
190 | |||
191 | public function setProperty($property, $value = false) |
||
200 | |||
201 | public function setLayout($layout) |
||
217 | |||
218 | /** |
||
219 | * Set the module for view look |
||
220 | * |
||
221 | * @access public |
||
222 | * @param string|bool $module module to override |
||
223 | */ |
||
224 | public function setModule($module = false) |
||
233 | |||
234 | /** |
||
235 | * Processes view/layouts and exposes variables to the view/layout |
||
236 | * |
||
237 | * @access private |
||
238 | * @param string $file file being rendered |
||
239 | * @return string processed content |
||
240 | */ |
||
241 | //@TODO: come back and clean up this and the way the view receives stuff |
||
242 | private function process($file) |
||
259 | |||
260 | /** |
||
261 | * Helper method for grabbing aggregated css files |
||
262 | * |
||
263 | * @access protected |
||
264 | * @return string css includes |
||
265 | */ |
||
266 | protected function fetchCSS() |
||
280 | |||
281 | /** |
||
282 | * Helper method for grabbing aggregated JS files |
||
283 | * |
||
284 | * @access protected |
||
285 | * @return string JS includes |
||
286 | */ |
||
287 | protected function fetchJS() |
||
301 | |||
302 | /** |
||
303 | * Helper method for adding css files for aggregation/render |
||
304 | * |
||
305 | * @access public |
||
306 | * @param $files array |
||
307 | * @param $place string |
||
308 | * @return string css includes |
||
309 | * @throws Exception\LookupException |
||
310 | */ |
||
311 | public function addCSS($files = [], $place = 'append') |
||
319 | |||
320 | public function addJS($files = [], $place = 'append') |
||
328 | |||
329 | /** |
||
330 | * Set 404 header, and return 404 view contents |
||
331 | * |
||
332 | * @access public |
||
333 | * @param $data array |
||
334 | * @return string |
||
335 | */ |
||
336 | public function render404($data = []) |
||
343 | } |
||
344 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..