forked from TYPO3/Fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultCaseViewHelper.php
More file actions
55 lines (49 loc) · 1.65 KB
/
DefaultCaseViewHelper.php
File metadata and controls
55 lines (49 loc) · 1.65 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
<?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\Compiler\TemplateCompiler;
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
use TYPO3Fluid\Fluid\Core\ViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* A ViewHelper which specifies the "default" case when used within the ``f:switch`` ViewHelper.
*
* @see \TYPO3Fluid\Fluid\ViewHelpers\SwitchViewHelper
*
* @api
*/
class DefaultCaseViewHelper extends AbstractViewHelper
{
/**
* @var boolean
*/
protected $escapeOutput = false;
/**
* @return string the contents of this ViewHelper if no other "Case" ViewHelper of the surrounding switch ViewHelper matches
* @throws ViewHelper\Exception
* @api
*/
public function render()
{
$viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
if (!$viewHelperVariableContainer->exists(SwitchViewHelper::class, 'switchExpression')) {
throw new ViewHelper\Exception('The "default case" ViewHelper can only be used within a switch ViewHelper', 1368112037);
}
return $this->renderChildren();
}
/**
* @param string $argumentsName
* @param string $closureName
* @param string $initializationPhpCode
* @param ViewHelperNode $node
* @param TemplateCompiler $compiler
* @return string
*/
public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
{
return '\'\'';
}
}