1 | <?php |
||
7 | class Renderer |
||
8 | { |
||
9 | /** |
||
10 | * Renderer configuration. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $config; |
||
15 | |||
16 | /** |
||
17 | * Page data to render. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $data; |
||
22 | |||
23 | /** |
||
24 | * Cache adapter. |
||
25 | * |
||
26 | * @var \Journey\Cache\CacheAdapterIterface |
||
27 | */ |
||
28 | protected $cache; |
||
29 | |||
30 | /** |
||
31 | * String data to output. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $output; |
||
36 | |||
37 | /** |
||
38 | * Template engine. |
||
39 | * |
||
40 | * @var \League\Plates\Engine |
||
41 | */ |
||
42 | protected $engine; |
||
43 | |||
44 | /** |
||
45 | * Fields that are required in order to render. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $required; |
||
50 | |||
51 | /** |
||
52 | * Name of the current theme. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $theme; |
||
57 | |||
58 | /** |
||
59 | * Initialize our new renderer. |
||
60 | */ |
||
61 | 10 | public function __construct(array $config, array $data) |
|
72 | |||
73 | /** |
||
74 | * Register custom theme functions particular function. |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | 10 | public function registerFunctions() |
|
84 | |||
85 | /** |
||
86 | * Add a single directory to the template engine. |
||
87 | * |
||
88 | * @param string $theme |
||
89 | * @param string $directory directory of templates |
||
90 | * @return $this |
||
91 | */ |
||
92 | 4 | public function registerTheme($theme, $directory) |
|
101 | |||
102 | /** |
||
103 | * Returns the template rendering engine. |
||
104 | * |
||
105 | * @return \League\Plates\Engine |
||
106 | */ |
||
107 | 1 | public function getEngine() |
|
111 | |||
112 | /** |
||
113 | * Get the page data that will be rendered. |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | 3 | public function getData() |
|
121 | |||
122 | /** |
||
123 | * Replace the page data |
||
124 | * |
||
125 | * @param array $data |
||
126 | */ |
||
127 | 10 | public function setData(array $data) |
|
133 | |||
134 | /** |
||
135 | * Validate that the page data is complete enough to render. |
||
136 | * |
||
137 | * Note: Throws an exception if the page data is incomplete. |
||
138 | * |
||
139 | * @param array $data array |
||
140 | * @return boolean |
||
141 | */ |
||
142 | 10 | public function validateData(array $data) |
|
149 | |||
150 | /** |
||
151 | * Generate wrapper classes for stripes |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 4 | public function wrapperClasses($string) |
|
160 | |||
161 | /** |
||
162 | * Returns the image url on the vssl server. |
||
163 | * |
||
164 | * @param string $name hash.extension |
||
165 | * @param string $style image style name |
||
166 | * @return string |
||
167 | */ |
||
168 | 2 | public function image($name, $style = false) |
|
172 | |||
173 | /** |
||
174 | * Strip most tags from output stored by the inline editor. |
||
175 | * |
||
176 | * @param string $str Output |
||
177 | * @param string $allowed_tags Permitted HTML tags |
||
178 | * @return string |
||
179 | */ |
||
180 | 2 | public function inline($str, $allowed_tags = '<a><b><strong><i><em>') |
|
184 | |||
185 | /** |
||
186 | * Process data before its output. This is the last chance to make changes |
||
187 | * to data before being passed to the actual template files. |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | 4 | public function processData($data) |
|
201 | |||
202 | /** |
||
203 | * Render the current data. |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | 4 | public function render() |
|
211 | |||
212 | /** |
||
213 | * Return the rendered page. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | 4 | public function __toString() |
|
225 | } |
||
226 |