a0cdb2cfa4799ceeed38a4ccb85da8ecf0ca2732
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / Widget / WidgetContext.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Widget;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * The WidgetContext stores all information a widget needs to know about the
19 * environment.
20 *
21 * The WidgetContext can be fetched from the current WidgetRequest, and is thus
22 * available throughout the whole sub-request of the widget. It is used internally
23 * by various ViewHelpers (like <f:widget.link>, <f:widget.uri>, <f:widget.renderChildren>),
24 * to get knowledge over the current widget's configuration.
25 *
26 * It is a purely internal class which should not be used outside of Fluid.
27 */
28 class WidgetContext
29 {
30 /**
31 * Uniquely idenfies a Widget Instance on a certain page.
32 *
33 * @var string
34 */
35 protected $widgetIdentifier;
36
37 /**
38 * Per-User unique identifier of the widget, if it is an AJAX widget.
39 *
40 * @var string
41 */
42 protected $ajaxWidgetIdentifier;
43
44 /**
45 * User-supplied widget configuration, available inside the widget
46 * controller as $this->widgetConfiguration.
47 *
48 * @var array
49 */
50 protected $widgetConfiguration;
51
52 /**
53 * The fully qualified object name of the Controller which this widget uses.
54 *
55 * @var string
56 */
57 protected $controllerObjectName;
58
59 /**
60 * The child nodes of the Widget ViewHelper.
61 * Only available inside non-AJAX requests.
62 *
63 * @var \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode
64 * @transient
65 */
66 protected $viewHelperChildNodes;
67
68 /**
69 * The rendering context of the ViewHelperChildNodes.
70 * Only available inside non-AJAX requests.
71 * @todo rename to something more meaningful.
72 *
73 * @var \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
74 * @transient
75 */
76 protected $viewHelperChildNodeRenderingContext;
77
78 /**
79 * @var string
80 */
81 protected $parentPluginNamespace;
82
83 /**
84 * @var string
85 */
86 protected $parentExtensionName;
87
88 /**
89 * @var string
90 */
91 protected $parentPluginName;
92
93 /**
94 * @var string
95 */
96 protected $widgetViewHelperClassName;
97
98 /**
99 * @return string
100 */
101 public function getWidgetIdentifier()
102 {
103 return $this->widgetIdentifier;
104 }
105
106 /**
107 * @param string $widgetIdentifier
108 */
109 public function setWidgetIdentifier($widgetIdentifier)
110 {
111 $this->widgetIdentifier = $widgetIdentifier;
112 }
113
114 /**
115 * @return string
116 */
117 public function getAjaxWidgetIdentifier()
118 {
119 return $this->ajaxWidgetIdentifier;
120 }
121
122 /**
123 * @param string $ajaxWidgetIdentifier
124 */
125 public function setAjaxWidgetIdentifier($ajaxWidgetIdentifier)
126 {
127 $this->ajaxWidgetIdentifier = $ajaxWidgetIdentifier;
128 }
129
130 /**
131 * Sets the URI namespace of the plugin that contains the widget
132 *
133 * @param string $parentPluginNamespace
134 */
135 public function setParentPluginNamespace($parentPluginNamespace)
136 {
137 $this->parentPluginNamespace = $parentPluginNamespace;
138 }
139
140 /**
141 * Returns the URI namespace of the plugin that contains the widget
142 *
143 * @return string
144 */
145 public function getParentPluginNamespace()
146 {
147 return $this->parentPluginNamespace;
148 }
149
150 /**
151 * Sets the Extension name of the plugin that contains the widget
152 *
153 * @param string $parentExtensionName
154 */
155 public function setParentExtensionName($parentExtensionName)
156 {
157 $this->parentExtensionName = $parentExtensionName;
158 }
159
160 /**
161 * Returns the Extension name of the plugin that contains the widget
162 *
163 * @return string
164 */
165 public function getParentExtensionName()
166 {
167 return $this->parentExtensionName;
168 }
169
170 /**
171 * Sets the name of the plugin that contains the widget
172 *
173 * @param string $parentPluginName
174 */
175 public function setParentPluginName($parentPluginName)
176 {
177 $this->parentPluginName = $parentPluginName;
178 }
179
180 /**
181 * Returns the name of the plugin that contains the widget
182 *
183 * @return string
184 */
185 public function getParentPluginName()
186 {
187 return $this->parentPluginName;
188 }
189
190 /**
191 * Sets the fully qualified class name of the view helper this context belongs to
192 *
193 * @param string $widgetViewHelperClassName
194 */
195 public function setWidgetViewHelperClassName($widgetViewHelperClassName)
196 {
197 $this->widgetViewHelperClassName = $widgetViewHelperClassName;
198 }
199
200 /**
201 * Returns the fully qualified class name of the view helper this context belongs to
202 *
203 * @return string
204 */
205 public function getWidgetViewHelperClassName()
206 {
207 return $this->widgetViewHelperClassName;
208 }
209
210 /**
211 * @return array
212 */
213 public function getWidgetConfiguration()
214 {
215 return $this->widgetConfiguration;
216 }
217
218 /**
219 * @param array $widgetConfiguration
220 */
221 public function setWidgetConfiguration($widgetConfiguration)
222 {
223 $this->widgetConfiguration = $widgetConfiguration;
224 }
225
226 /**
227 * @return string
228 */
229 public function getControllerObjectName()
230 {
231 return $this->controllerObjectName;
232 }
233
234 /**
235 * @param string $controllerObjectName
236 */
237 public function setControllerObjectName($controllerObjectName)
238 {
239 $this->controllerObjectName = $controllerObjectName;
240 }
241
242 /**
243 * @param \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode $viewHelperChildNodes
244 * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $viewHelperChildNodeRenderingContext
245 */
246 public function setViewHelperChildNodes(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode $viewHelperChildNodes, \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $viewHelperChildNodeRenderingContext)
247 {
248 $this->viewHelperChildNodes = $viewHelperChildNodes;
249 $this->viewHelperChildNodeRenderingContext = $viewHelperChildNodeRenderingContext;
250 }
251
252 /**
253 * @return \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode
254 */
255 public function getViewHelperChildNodes()
256 {
257 return $this->viewHelperChildNodes;
258 }
259
260 /**
261 * @return \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
262 */
263 public function getViewHelperChildNodeRenderingContext()
264 {
265 return $this->viewHelperChildNodeRenderingContext;
266 }
267
268 /**
269 * @return array
270 */
271 public function __sleep()
272 {
273 return ['widgetIdentifier', 'ajaxWidgetIdentifier', 'widgetConfiguration', 'controllerObjectName', 'parentPluginNamespace', 'parentExtensionName', 'parentPluginName', 'widgetViewHelperClassName'];
274 }
275 }