1
|
|
|
<?php |
2
|
|
|
namespace TYPO3Fluid\Fluid\ViewHelpers; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file belongs to the package "TYPO3 Fluid". |
6
|
|
|
* See LICENSE.txt that was shipped with this package. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler; |
10
|
|
|
use TYPO3Fluid\Fluid\Core\Parser\NodeFilterInterface; |
11
|
|
|
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\NodeInterface; |
12
|
|
|
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode; |
13
|
|
|
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode; |
14
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* "THEN" -> only has an effect inside of "IF". See If-ViewHelper for documentation. |
18
|
|
|
* |
19
|
|
|
* @see \TYPO3Fluid\Fluid\ViewHelpers\IfViewHelper |
20
|
|
|
* @api |
21
|
|
|
*/ |
22
|
|
|
class ThenViewHelper extends AbstractViewHelper implements NodeFilterInterface |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var boolean |
27
|
|
|
*/ |
28
|
|
|
protected $escapeOutput = false; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Just render everything. |
32
|
|
|
* |
33
|
|
|
* @return string the rendered string |
34
|
|
|
* @api |
35
|
|
|
*/ |
36
|
|
|
public function render() |
37
|
|
|
{ |
38
|
|
|
return $this->renderChildren(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Condition ViewHelpers disallow child nodes that consist purely of whitespace, |
43
|
|
|
* thus avoiding whitespace in output inside f:if structures but not inside any |
44
|
|
|
* f:then or f:else nodes. |
45
|
|
|
* |
46
|
|
|
* @param NodeInterface $node |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
|
View Code Duplication |
public function allowsChildNodeType(NodeInterface $node): bool |
|
|
|
|
50
|
|
|
{ |
51
|
|
|
if ($node instanceof TextNode && trim($node->getText()) === '') { |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $argumentsName |
59
|
|
|
* @param string $closureName |
60
|
|
|
* @param string $initializationPhpCode |
61
|
|
|
* @param ViewHelperNode $node |
62
|
|
|
* @param TemplateCompiler $compiler |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler) |
66
|
|
|
{ |
67
|
|
|
return '\'\''; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.