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 | * BaseComponent constructor. |
||
38 | * |
||
39 | * @param string $template |
||
40 | * @param Request $request |
||
41 | * @param array $parameters |
||
42 | * @param $matchedSitemapItem |
||
43 | */ |
||
44 | public function __construct($template = '', Request $request, $parameters = array(), $matchedSitemapItem) |
||
51 | |||
52 | /** |
||
53 | * Hook for implementation in derived classes |
||
54 | * |
||
55 | * @param Storage $storage |
||
56 | */ |
||
57 | public function run(Storage $storage) |
||
61 | |||
62 | /** |
||
63 | * Renders the template |
||
64 | * |
||
65 | * @param null|Application $application |
||
66 | * |
||
67 | * @throws \Exception |
||
68 | */ |
||
69 | public function render($application = null) |
||
73 | |||
74 | /** |
||
75 | * Returns the rendered content |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function get() |
||
83 | |||
84 | /** |
||
85 | * Decoupled render method, for usage in derived classes |
||
86 | * |
||
87 | * @param string $template |
||
88 | * |
||
89 | * @param bool $obClean |
||
90 | * @param null | Application $application |
||
91 | * |
||
92 | * @return string |
||
93 | * @throws \Exception |
||
94 | */ |
||
95 | public function renderTemplate($template = '', $obClean = true, $application = null) |
||
118 | |||
119 | /** |
||
120 | * Alias for renderTemplate for usage to include templates in other templates |
||
121 | * |
||
122 | * @param string $template |
||
123 | * |
||
124 | * @param array $parameters |
||
125 | * |
||
126 | * @return string |
||
127 | * @throws \Exception |
||
128 | */ |
||
129 | public function includeTemplate($template = '', $parameters = array()) |
||
138 | |||
139 | public function getParameters() |
||
143 | |||
144 | /** |
||
145 | * @param $template |
||
146 | * @param null | Application $application |
||
147 | * @return string |
||
148 | */ |
||
149 | protected function getTemplateDir($template, $application = null) |
||
158 | |||
159 | /** |
||
160 | * @param $template |
||
161 | * @param $application |
||
162 | * @return string |
||
163 | */ |
||
164 | private function getTemplatePath($template, $application) |
||
179 | } |
||
180 | } |