1 | <?php |
||
9 | class BaseComponent implements Component |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $template; |
||
15 | /** |
||
16 | * @var \CloudControl\Cms\cc\Request |
||
17 | */ |
||
18 | protected $request; |
||
19 | /** |
||
20 | * @var Storage |
||
21 | */ |
||
22 | protected $storage; |
||
23 | /** |
||
24 | * @var mixed |
||
25 | */ |
||
26 | protected $renderedContent; |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $parameters = array(); |
||
31 | /*** |
||
32 | * @var \stdClass |
||
33 | */ |
||
34 | protected $matchedSitemapItem; |
||
35 | |||
36 | /** |
||
37 | * @var Application |
||
38 | */ |
||
39 | protected $application = null; |
||
40 | |||
41 | /** |
||
42 | * BaseComponent constructor. |
||
43 | * |
||
44 | * @param string $template |
||
45 | * @param Request $request |
||
46 | * @param array $parameters |
||
47 | * @param $matchedSitemapItem |
||
48 | */ |
||
49 | public function __construct($template = '', Request $request, $parameters = array(), $matchedSitemapItem) |
||
56 | |||
57 | /** |
||
58 | * Hook for implementation in derived classes |
||
59 | * |
||
60 | * @param Storage $storage |
||
61 | */ |
||
62 | public function run(Storage $storage) |
||
66 | |||
67 | /** |
||
68 | * Renders the template |
||
69 | * |
||
70 | * @param null|Application $application |
||
71 | * |
||
72 | * @throws \Exception |
||
73 | */ |
||
74 | public function render($application = null) |
||
79 | |||
80 | /** |
||
81 | * Returns the rendered content |
||
82 | * |
||
83 | * @return mixed |
||
84 | */ |
||
85 | public function get() |
||
89 | |||
90 | /** |
||
91 | * Decoupled render method, for usage in derived classes |
||
92 | * |
||
93 | * @param string $template |
||
94 | * |
||
95 | * @param bool $obClean |
||
96 | * @param null | Application $application |
||
97 | * @param Application $application |
||
98 | * |
||
99 | * @return string |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | public function renderTemplate($template = '', $obClean = true, $application = null) |
||
116 | |||
117 | /** |
||
118 | * Alias for renderTemplate for usage to include templates in other templates |
||
119 | * |
||
120 | * @param string $template |
||
121 | * |
||
122 | * @param array $parameters |
||
123 | * |
||
124 | * @return string |
||
125 | * @throws \Exception |
||
126 | */ |
||
127 | public function includeTemplate($template = '', $parameters = array()) |
||
136 | |||
137 | public function getParameters() |
||
141 | |||
142 | /** |
||
143 | * @param $template |
||
144 | * @param null | Application $application |
||
145 | * @return string |
||
146 | */ |
||
147 | protected function getTemplateDir($template, $application = null) |
||
156 | |||
157 | /** |
||
158 | * @param string $template |
||
159 | * @param Application $application |
||
160 | * @return string |
||
161 | */ |
||
162 | private function getTemplatePath($template, $application = null) |
||
174 | |||
175 | /** |
||
176 | * @param Application $application |
||
177 | * @param string $templateDir |
||
178 | * @return string |
||
179 | */ |
||
180 | private function getTemplatePathFromApplication($application, $templateDir) |
||
191 | |||
192 | /** |
||
193 | * @param $templatePath |
||
194 | * @param $obClean |
||
195 | * @return mixed|string |
||
196 | */ |
||
197 | private function includeTemplateFile($templatePath, $obClean) |
||
206 | |||
207 | /** |
||
208 | * @param string $templatePath |
||
209 | * @param Application $application |
||
210 | * @param bool $obClean |
||
211 | * @return mixed|string |
||
212 | */ |
||
213 | private function extractParametersAndIncludeTemplateFile($templatePath, $application = null, $obClean = true) |
||
225 | } |
||
226 | } |