1 | <?php |
||
28 | class MiniView implements ViewRendererInterface, OwnerAwareInterface, RendererAwareInterface |
||
29 | { |
||
30 | |||
31 | use Traits\OwnerAwareTrait, |
||
32 | Traits\RendererAwareTrait; |
||
33 | |||
34 | /** |
||
35 | * Current version |
||
36 | * @var string |
||
37 | */ |
||
38 | private static $version = null; |
||
39 | |||
40 | /** |
||
41 | * View path |
||
42 | * @var string |
||
43 | */ |
||
44 | private $path = ''; |
||
45 | |||
46 | /** |
||
47 | * View path. This is relative to base path. |
||
48 | * @var string |
||
49 | */ |
||
50 | private $viewsPath = 'views'; |
||
51 | |||
52 | /** |
||
53 | * Create MiniView instance. If path is not set, it will be based on location of owner class. |
||
54 | * @param object $owner |
||
55 | * @param string $path |
||
56 | */ |
||
57 | public function __construct($owner, $path = null) |
||
62 | |||
63 | /** |
||
64 | * Get current MiniView version |
||
65 | * @return string Version string |
||
66 | */ |
||
67 | public function getVersion() |
||
75 | |||
76 | /** |
||
77 | * Set views path. This is relative path for view resolving. |
||
78 | * By default it's `views` folder. |
||
79 | * @param string $path |
||
80 | */ |
||
81 | public function setViewsPath($path) |
||
85 | |||
86 | /** |
||
87 | * Render view with data provided. |
||
88 | * View name must not contain `php` extension. |
||
89 | * @param string $view |
||
90 | * @param mixed[] $data |
||
91 | * @param bool $return |
||
92 | * @return string |
||
93 | */ |
||
94 | public function render($view, $data = null, $return = false) |
||
99 | |||
100 | /** |
||
101 | * Render file with data provided. |
||
102 | * @param string $file |
||
103 | * @param mixed[] $data |
||
104 | * @param bool $return |
||
105 | * @return string |
||
106 | */ |
||
107 | public function renderFile($file, $data = null, $return = false) |
||
111 | |||
112 | function getPath() |
||
121 | |||
122 | } |
||
123 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.