1 | <?php |
||
18 | class View implements ViewInterface |
||
19 | { |
||
20 | /** Default view file extension */ |
||
21 | const DEFAULT_EXT = 'vphp'; |
||
22 | |||
23 | /** @var array Collection of $key => $value view data */ |
||
24 | protected $data = array(); |
||
25 | |||
26 | /** @var string Full path to view file */ |
||
27 | protected $file; |
||
28 | |||
29 | /** @var string View source code */ |
||
30 | protected $source; |
||
31 | |||
32 | /** @var string Rendered view contents */ |
||
33 | protected $output; |
||
34 | |||
35 | /** @var string Parent view class name */ |
||
36 | protected $parentView; |
||
37 | |||
38 | /** @var string Parent view block name */ |
||
39 | protected $parentBlock; |
||
40 | |||
41 | /** @var array Collection of view blocks */ |
||
42 | protected $blocks = array(); |
||
43 | |||
44 | /** |
||
45 | * Set current view for rendering. |
||
46 | * Method searches for the shortest matching view path by $pathPattern, |
||
47 | * from loaded views. |
||
48 | * |
||
49 | * Module saves all view data that has been set to a specific view in appropriate |
||
50 | * view data collection entry. By default module creates vied data entry - VD_POINTER_DEF, |
||
51 | * and until any call of iModule::view() or iModule::output(), all data that is iModule::set(), |
||
52 | * is stored to that location. |
||
53 | * |
||
54 | * On the first call of iModule::view() or iModule::output(), this method changes the view data |
||
55 | * pointer to actual relative view path, and copies(actually just sets view data pointer) all view |
||
56 | * data set before to new view data pointer. This guarantees backward compatibility and gives |
||
57 | * opportunity not to set the view path before setting view data to it. |
||
58 | * |
||
59 | * @param string $pathPattern Path pattern for view searching |
||
60 | * |
||
61 | * @return $this Chaining |
||
62 | * @throws \Exception |
||
63 | */ |
||
64 | 2 | public function view($pathPattern) |
|
73 | |||
74 | /** |
||
75 | * Render current view. |
||
76 | * Method uses current view context and outputs rendering |
||
77 | * result. |
||
78 | * |
||
79 | * @return string Rendered view |
||
80 | */ |
||
81 | 3 | public function output() |
|
110 | |||
111 | /** |
||
112 | * Magic method for getting view variables. |
||
113 | * |
||
114 | * @param string $name Variable key |
||
115 | * |
||
116 | * @return mixed Value |
||
117 | * @throws VariableKeyNotFound |
||
118 | */ |
||
119 | 5 | public function __get($name) |
|
127 | |||
128 | /** |
||
129 | * Set current view parent rendering view and block. |
||
130 | * |
||
131 | * @param string $parent Fully qualified parent view name |
||
132 | * @param string $block View block for rendering in parent view |
||
133 | * |
||
134 | * @throws ViewClassNotFound |
||
135 | */ |
||
136 | 1 | public function extend($parent, $block) |
|
143 | |||
144 | /** |
||
145 | * Set current view nested block rendering view. |
||
146 | * |
||
147 | * @param string $blockName Nested view block container |
||
148 | */ |
||
149 | public function block($blockName) |
||
153 | |||
154 | /** |
||
155 | * Magic method for setting view variables. |
||
156 | * |
||
157 | * @param string $name Variable key |
||
158 | * @param array $arguments Variable value |
||
159 | * |
||
160 | * @return $this Chaining |
||
161 | * @throws VariableKeyNotFound |
||
162 | */ |
||
163 | 1 | public function __call($name, $arguments) |
|
171 | |||
172 | /** |
||
173 | * Set view variable. |
||
174 | * |
||
175 | * Passing an array as $value will add array key => values into current |
||
176 | * view data collection. If $key is passed then an array variable with this |
||
177 | * key will be added to view data collection beside adding array key => values. |
||
178 | * |
||
179 | * @param mixed $value Variable value |
||
180 | * @param string|null $key Variable key\prefix for objects and arrays |
||
181 | * |
||
182 | * @return $this Chaining |
||
183 | */ |
||
184 | 7 | public function set($value, $key = null) |
|
198 | |||
199 | /** |
||
200 | * Set renderable object as view variable. |
||
201 | * |
||
202 | * @param mixed $object Object instance for rendering |
||
203 | * @param string|null $key Variable key\prefix for objects and arrays |
||
204 | */ |
||
205 | 3 | protected function setRenderableObject($object, $key) |
|
214 | } |
||
215 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.