1 | <?php |
||
20 | class Twig implements TemplateInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var array the config for twig |
||
24 | */ |
||
25 | protected $config; |
||
26 | |||
27 | /** |
||
28 | * @var Page the page model |
||
29 | */ |
||
30 | protected $page; |
||
31 | |||
32 | /** |
||
33 | * @var string theme name |
||
34 | */ |
||
35 | protected $theme; |
||
36 | |||
37 | /** |
||
38 | * @var string path to theme directory |
||
39 | */ |
||
40 | protected $themesDir; |
||
41 | |||
42 | /** |
||
43 | * the constructor |
||
44 | * |
||
45 | * @param array $config the configuration |
||
46 | */ |
||
47 | 28 | public function __construct(array $config = []) |
|
54 | |||
55 | /** |
||
56 | * method to set the current page |
||
57 | * |
||
58 | * @param Page $page the page model |
||
59 | * |
||
60 | * @return mixed|void |
||
61 | */ |
||
62 | 3 | public function setCurrentPage(Page $page) |
|
66 | |||
67 | /** |
||
68 | * method to render the page/template |
||
69 | * |
||
70 | * @return mixed|string |
||
71 | */ |
||
72 | 3 | public function render() |
|
82 | |||
83 | /** |
||
84 | * wrapper to call the render engine |
||
85 | * |
||
86 | * @param \Twig_Environment $engine |
||
87 | * @param array $vars |
||
88 | * @return string |
||
89 | */ |
||
90 | 3 | protected function doRender(\Twig_Environment $engine, array $vars): string |
|
99 | |||
100 | /** |
||
101 | * get template engine |
||
102 | * |
||
103 | * @return \Twig_Environment |
||
104 | */ |
||
105 | 3 | protected function getEngine() |
|
116 | |||
117 | /** |
||
118 | * get template file name |
||
119 | * |
||
120 | * @return string |
||
121 | * @throws \RuntimeException |
||
122 | */ |
||
123 | 3 | protected function getTemplateFileName(): string |
|
141 | |||
142 | /** |
||
143 | * get file path to (sub-path) in theme-path |
||
144 | * |
||
145 | * @param string $sub |
||
146 | * @return string |
||
147 | */ |
||
148 | 3 | protected function getTemplatePath(string $sub = ''): string |
|
156 | |||
157 | /** |
||
158 | * get template vars |
||
159 | * |
||
160 | * @return array |
||
161 | * @throws \Exception |
||
162 | */ |
||
163 | 3 | protected function getTemplateVars(): array |
|
180 | } |
||
181 |