[TASK] Merge submodule linkvalidator into core
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / LayoutViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * With this tag, you can select a layout to be used for the current template.
16 *
17 * = Examples =
18 *
19 * <code>
20 * <f:layout name="main" />
21 * </code>
22 * <output>
23 * (no output)
24 * </output>
25 *
26 * @api
27 */
28 class LayoutViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper implements \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\PostParseInterface {
29
30 /**
31 * Initialize arguments
32 *
33 * @return void
34 * @api
35 */
36 public function initializeArguments() {
37 $this->registerArgument('name', 'string', 'Name of layout to use. If none given, "Default" is used.', TRUE);
38 }
39
40 /**
41 * On the post parse event, add the "layoutName" variable to the variable container so it can be used by the TemplateView.
42 *
43 * @param \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode
44 * @param array $viewHelperArguments
45 * @param \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer
46 * @return void
47 */
48 static public function postParseEvent(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer) {
49 if (isset($viewHelperArguments['name'])) {
50 $layoutNameNode = $viewHelperArguments['name'];
51 } else {
52 $layoutNameNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode('Default');
53 }
54
55 $variableContainer->add('layoutName', $layoutNameNode);
56 }
57
58 /**
59 * This tag will not be rendered at all.
60 *
61 * @return void
62 * @api
63 */
64 public function render() {
65 }
66 }
67
68 ?>