forked from TYPO3/Fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayoutViewHelper.php
More file actions
68 lines (62 loc) · 1.71 KB
/
LayoutViewHelper.php
File metadata and controls
68 lines (62 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace TYPO3Fluid\Fluid\ViewHelpers;
/*
* This file belongs to the package "TYPO3 Fluid".
* See LICENSE.txt that was shipped with this package.
*/
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
use TYPO3Fluid\Fluid\Core\Variables\VariableProviderInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\PostParseInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\TemplateVariableContainer;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\ParserRuntimeOnly;
/**
* With this tag, you can select a layout to be used for the current template.
*
* Examples
* ========
*
* ::
*
* <f:layout name="main" />
*
* Output::
*
* (no output)
*
* @api
*/
class LayoutViewHelper extends AbstractViewHelper
{
use ParserRuntimeOnly;
/**
* Initialize arguments
*
* @return void
* @api
*/
public function initializeArguments()
{
$this->registerArgument('name', 'string', 'Name of layout to use. If none given, "Default" is used.');
}
/**
* On the post parse event, add the "layoutName" variable to the variable container so it can be used by the TemplateView.
*
* @param ViewHelperNode $node
* @param array $arguments
* @param VariableProviderInterface $variableContainer
* @return void
*/
public static function postParseEvent(
ViewHelperNode $node,
array $arguments,
VariableProviderInterface $variableContainer
) {
if (isset($arguments['name'])) {
$layoutNameNode = $arguments['name'];
} else {
$layoutNameNode = 'Default';
}
$variableContainer->add('layoutName', $layoutNameNode);
}
}