1 | <?php |
||
17 | class View implements ViewInterface |
||
18 | { |
||
19 | /** Default view file extension */ |
||
20 | const DEFAULT_EXT = 'vphp'; |
||
21 | |||
22 | /** @var array Collection of $key => $value view data */ |
||
23 | protected $data = array(); |
||
24 | |||
25 | /** @var string Full path to view file */ |
||
26 | protected $file; |
||
27 | |||
28 | /** @var string View source code */ |
||
29 | protected $source; |
||
30 | |||
31 | /** @var string Rendered view contents */ |
||
32 | protected $output; |
||
33 | |||
34 | /** @var string Parent view block name */ |
||
35 | protected $parentBlock; |
||
36 | |||
37 | /** @var array Collection of view blocks */ |
||
38 | protected $blocks = array(); |
||
39 | |||
40 | /** @var array Blocks html list */ |
||
41 | protected $blocksHtml = array(); |
||
42 | |||
43 | /** |
||
44 | * Set current view for rendering. |
||
45 | * Method searches for the shortest matching view path by $pathPattern, |
||
46 | * from loaded views. |
||
47 | * |
||
48 | * Module saves all view data that has been set to a specific view in appropriate |
||
49 | * view data collection entry. By default module creates vied data entry - VD_POINTER_DEF, |
||
50 | * and until any call of iModule::view() or iModule::output(), all data that is iModule::set(), |
||
51 | * is stored to that location. |
||
52 | * |
||
53 | * On the first call of iModule::view() or iModule::output(), this method changes the view data |
||
54 | * pointer to actual relative view path, and copies(actually just sets view data pointer) all view |
||
55 | * data set before to new view data pointer. This guarantees backward compatibility and gives |
||
56 | * opportunity not to set the view path before setting view data to it. |
||
57 | * |
||
58 | * @param string $pathPattern Path pattern for view searching |
||
59 | * |
||
60 | * @return $this Chaining |
||
61 | * @throws \Exception |
||
62 | */ |
||
63 | 2 | public function view($pathPattern) |
|
72 | |||
73 | /** |
||
74 | * Render current view. |
||
75 | * Method uses current view context and outputs rendering |
||
76 | * result. |
||
77 | * |
||
78 | * @param bool $onlyCurrent Render only current view without extends |
||
79 | * @return string Rendered view |
||
80 | */ |
||
81 | 3 | public function output($onlyCurrent = false) |
|
88 | |||
89 | |||
90 | /** |
||
91 | * Render full views stack. |
||
92 | * |
||
93 | * @param bool $onlyCurrent Render only current view without extends |
||
94 | * @param array $blocksList Block for rendering in the view |
||
95 | * @param array $data View data collection |
||
96 | * |
||
97 | * @return string Rendered view |
||
98 | */ |
||
99 | 3 | public function innerOutput($onlyCurrent = false, array $blocksList = array(), array $data = array()) |
|
142 | |||
143 | /** |
||
144 | * Magic method for getting view variables. |
||
145 | * |
||
146 | * @param string $name Variable key |
||
147 | * |
||
148 | * @return mixed Value |
||
149 | * @throws VariableKeyNotFound |
||
150 | */ |
||
151 | 5 | public function __get($name) |
|
159 | |||
160 | /** |
||
161 | * Set current view parent rendering view and block. |
||
162 | * |
||
163 | * @param string $parent Fully qualified parent view name |
||
164 | * @param string $block View block for rendering in parent view |
||
165 | */ |
||
166 | 1 | public function extend($parent, $block) |
|
170 | |||
171 | /** |
||
172 | * Set current view nested block rendering view. |
||
173 | * |
||
174 | * @param string $blockName Nested view block container |
||
175 | */ |
||
176 | 1 | public function block($blockName) |
|
182 | |||
183 | /** |
||
184 | * Magic method for setting view variables. |
||
185 | * |
||
186 | * @param string $name Variable key |
||
187 | * @param array $arguments Variable value |
||
188 | * |
||
189 | * @return $this Chaining |
||
190 | * @throws VariableKeyNotFound |
||
191 | */ |
||
192 | 1 | public function __call($name, $arguments) |
|
200 | |||
201 | /** |
||
202 | * Set view variable. |
||
203 | * |
||
204 | * Passing an array as $value will add array key => values into current |
||
205 | * view data collection. If $key is passed then an array variable with this |
||
206 | * key will be added to view data collection beside adding array key => values. |
||
207 | * |
||
208 | * @param mixed $value Variable value |
||
209 | * @param string|null $key Variable key\prefix for objects and arrays |
||
210 | * |
||
211 | * @return $this Chaining |
||
212 | */ |
||
213 | 7 | public function set($value, $key = null) |
|
227 | |||
228 | |||
229 | /** |
||
230 | * Set renderable object as view variable. |
||
231 | * |
||
232 | * @param mixed $object Object instance for rendering |
||
233 | * @param string|null $key Variable key\prefix for objects and arrays |
||
234 | */ |
||
235 | 3 | protected function setRenderableObject($object, $key) |
|
244 | } |
||
245 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.