[-TASK] Fluid: Removed all @scope annotations as they are not used in v4
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / RenderViewHelper.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 *
25 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
26 * @api
27 */
28 class Tx_Fluid_ViewHelpers_RenderViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
29
30 /**
31 * Renders the content.
32 *
33 * @param string $section Name of section to render. If used in a layout, renders a section of the main content file. If used inside a standard template, renders a section of the same file.
34 * @param string $partial Reference to a partial.
35 * @param array $arguments Arguments to pass to the partial.
36 * @return string
37 * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
38 * @api
39 */
40 public function render($section = NULL, $partial = NULL, $arguments = array()) {
41 $arguments = $this->loadSettingsIntoArguments($arguments);
42
43 if ($partial !== NULL) {
44 return $this->viewHelperVariableContainer->getView()->renderPartial($partial, $section, $arguments);
45 } elseif ($section !== NULL) {
46 return $this->viewHelperVariableContainer->getView()->renderSection($section, $arguments);
47 }
48 return '';
49 }
50
51 /**
52 * If $arguments['settings'] is not set, it is loaded from the TemplateVariableContainer (if it is available there).
53 *
54 * @param array $arguments
55 * @return array
56 */
57 protected function loadSettingsIntoArguments($arguments) {
58 if (!isset($arguments['settings']) && $this->templateVariableContainer->exists('settings')) {
59 $arguments['settings'] = $this->templateVariableContainer->get('settings');
60 }
61 return $arguments;
62 }
63 }
64
65 ?>