1 | <?php |
||
30 | class MiniView implements ViewRendererInterface, OwnerAwareInterface, RendererAwareInterface |
||
31 | { |
||
32 | |||
33 | use Traits\OwnerAwareTrait, |
||
34 | Traits\RendererAwareTrait; |
||
35 | |||
36 | public $renderers = [ |
||
37 | 'latte' => LatteRenderer::class, |
||
38 | 'php' => PhpRenderer::class |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * Current version |
||
43 | * @var string |
||
44 | */ |
||
45 | private static $version = null; |
||
46 | |||
47 | /** |
||
48 | * View path |
||
49 | * @var string |
||
50 | */ |
||
51 | private $path = ''; |
||
52 | |||
53 | /** |
||
54 | * View path. This is relative to base path. |
||
55 | * @var string |
||
56 | */ |
||
57 | private $viewsPath = 'views'; |
||
58 | |||
59 | /** |
||
60 | * Create MiniView instance. If path is not set, it will be based on location of owner class. |
||
61 | * @param object $owner |
||
62 | * @param string $path |
||
63 | */ |
||
64 | public function __construct($owner, $path = null) |
||
69 | |||
70 | /** |
||
71 | * Get current MiniView version |
||
72 | * @return string Version string |
||
73 | */ |
||
74 | public function getVersion() |
||
82 | |||
83 | /** |
||
84 | * Set views path. This is relative path for view resolving. |
||
85 | * By default it's `views` folder. |
||
86 | * @param string $path |
||
87 | */ |
||
88 | public function setViewsPath($path) |
||
92 | |||
93 | /** |
||
94 | * Render view with data provided. |
||
95 | * View name may contain `php` extension. If no extension is passed or |
||
96 | * it not match extensions from renderer configuration, |
||
97 | * it will append extension based on current renderer. |
||
98 | * |
||
99 | * Example with default or previously set renderer: |
||
100 | * |
||
101 | * ```php |
||
102 | * $view->render('myView'); |
||
103 | * ``` |
||
104 | * |
||
105 | * Example with enforced php renderer: |
||
106 | * |
||
107 | * ```php |
||
108 | * $view->render('myView.php'); |
||
109 | * ``` |
||
110 | * |
||
111 | * Example with enforced latte renderer: |
||
112 | * |
||
113 | * ```php |
||
114 | * $view->render('myView.latte'); |
||
115 | * ``` |
||
116 | * |
||
117 | * @param string $view |
||
118 | * @param mixed[] $data |
||
119 | * @param bool $return |
||
120 | * @return string |
||
121 | */ |
||
122 | public function render($view, $data = null, $return = false) |
||
161 | |||
162 | /** |
||
163 | * Render file with data provided. |
||
164 | * @param string $file |
||
165 | * @param mixed[] $data |
||
166 | * @param bool $return |
||
167 | * @return string |
||
168 | */ |
||
169 | public function renderFile($file, $data = null, $return = false) |
||
173 | |||
174 | function getPath() |
||
183 | |||
184 | } |
||
185 |
It seems like you are relying on a variable being defined by an iteration: