1 | <?php |
||
12 | class View |
||
13 | { |
||
14 | /** |
||
15 | * @var $template Template file or array |
||
16 | * @var $templateData Data to send to template file |
||
17 | * @var $sortOrder For sorting views |
||
18 | * @var $type Type of view |
||
19 | */ |
||
20 | private $template; |
||
21 | private $templateData = []; |
||
22 | private $sortOrder; |
||
23 | private $type; |
||
24 | |||
25 | |||
26 | |||
27 | /** |
||
28 | * Set values for the view. |
||
29 | * |
||
30 | * @param array|string $template the template file, or array |
||
31 | * @param array $data variables to make available to the |
||
32 | * view, default is empty |
||
33 | * @param integer $sort which order to display the views, |
||
34 | * if suitable |
||
35 | * @param string $type which type of view |
||
36 | * |
||
37 | * @return self |
||
38 | */ |
||
39 | 2 | public function set($template, $data = [], $sort = 0, $type = "file") |
|
79 | |||
80 | |||
81 | |||
82 | /** |
||
83 | * Render the view by its type. |
||
84 | * |
||
85 | * @param object $di optional with access to the framework resources. |
||
86 | * |
||
87 | * @return void |
||
88 | */ |
||
89 | 2 | public function render(ContainerInterface $di = null) |
|
120 | |||
121 | |||
122 | |||
123 | /** |
||
124 | * Give the sort order for this view. |
||
125 | * |
||
126 | * @return int |
||
127 | */ |
||
128 | public function sortOrder() |
||
132 | } |
||
133 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: