Skip to content

Commit 0e4a73c

Browse files
committed
[BUGFIX] Remove usage of ConditionViewHelperTrait
Fixes compiled rendering issues with various condition ViewHelpers.
1 parent 7669d06 commit 0e4a73c

31 files changed

+49
-280
lines changed

Classes/Traits/ConditionViewHelperTrait.php

Lines changed: 1 addition & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -8,137 +8,9 @@
88
* LICENSE.md file that was distributed with this source code.
99
*/
1010

11-
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
12-
1311
/**
14-
* This trait can be used by viewhelpers that generate image tags
15-
* to add srcsets based to the imagetag for better responsiveness
12+
* @deprecated no longer required since TYPO3 7.6
1613
*/
1714
trait ConditionViewHelperTrait
1815
{
19-
20-
/**
21-
* renders <f:then> child if $condition is true, otherwise renders <f:else> child.
22-
*
23-
* @return string the rendered string
24-
* @api
25-
*/
26-
public function render()
27-
{
28-
if (static::evaluateCondition($this->arguments)) {
29-
return $this->renderThenChild();
30-
} else {
31-
return $this->renderElseChild();
32-
}
33-
}
34-
35-
/**
36-
* Default implementation for use in compiled templates
37-
*
38-
* TODO: remove at some point, because this is only here for legacy reasons.
39-
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
40-
* method. 7.2+ on the other hand provides basically exactly this method here
41-
* luckily it's backwards compatible out of the box.
42-
* tl;dr -> remove after expiration of support for anything below 7.2
43-
*
44-
* @param array $arguments
45-
* @param \Closure $renderChildrenClosure
46-
* @param RenderingContextInterface $renderingContext
47-
* @return mixed
48-
*/
49-
static public function renderStatic(
50-
array $arguments,
51-
\Closure $renderChildrenClosure,
52-
RenderingContextInterface $renderingContext
53-
) {
54-
$hasEvaluated = true;
55-
if (static::evaluateCondition($arguments)) {
56-
$result = static::renderStaticThenChild($arguments, $hasEvaluated);
57-
if ($hasEvaluated) {
58-
return $result;
59-
}
60-
61-
return $renderChildrenClosure();
62-
} else {
63-
$result = static::renderStaticElseChild($arguments, $hasEvaluated);
64-
if ($hasEvaluated) {
65-
return $result;
66-
}
67-
}
68-
69-
return '';
70-
}
71-
72-
/**
73-
* Statically evalute "then" children.
74-
* The "$hasEvaluated" argument is there to distinguish the case that "then" returned NULL or was not evaluated.
75-
*
76-
* TODO: remove at some point, because this is only here for legacy reasons.
77-
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
78-
* method. 7.2+ on the other hand provides basically exactly this method here
79-
* luckily it's backwards compatible out of the box.
80-
* tl;dr -> remove after expiration of support for anything below 7.2
81-
*
82-
* @param array $arguments ViewHelper arguments
83-
* @param bool $hasEvaluated Can be used to check if the "then" child was actually evaluated by this method.
84-
* @return string
85-
*/
86-
static protected function renderStaticThenChild($arguments, &$hasEvaluated)
87-
{
88-
if (isset($arguments['then'])) {
89-
return $arguments['then'];
90-
}
91-
if (isset($arguments['__thenClosure'])) {
92-
$thenClosure = $arguments['__thenClosure'];
93-
return $thenClosure();
94-
} elseif (isset($arguments['__elseClosure'])) {
95-
return '';
96-
}
97-
98-
$hasEvaluated = false;
99-
}
100-
101-
/**
102-
* Statically evalute "else" children.
103-
* The "$hasEvaluated" argument is there to distinguish the case that "else" returned NULL or was not evaluated.
104-
*
105-
* TODO: remove at some point, because this is only here for legacy reasons.
106-
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
107-
* method. 7.2+ on the other hand provides basically exactly this method here
108-
* luckily it's backwards compatible out of the box.
109-
* tl;dr -> remove after expiration of support for anything below 7.2
110-
*
111-
* @param array $arguments ViewHelper arguments
112-
* @param bool $hasEvaluated Can be used to check if the "else" child was actually evaluated by this method.
113-
* @return string
114-
*/
115-
static protected function renderStaticElseChild($arguments, &$hasEvaluated)
116-
{
117-
if (isset($arguments['else'])) {
118-
return $arguments['else'];
119-
}
120-
if (isset($arguments['__elseClosure'])) {
121-
$elseClosure = $arguments['__elseClosure'];
122-
return $elseClosure();
123-
}
124-
125-
$hasEvaluated = false;
126-
}
127-
128-
/**
129-
* This method decides if the condition is TRUE or FALSE.
130-
*
131-
* TODO: remove at some point, because this is only here for legacy reasons.
132-
* the AbstractConditionViewHelper in 6.2.* doesn't have a default render
133-
* method. 7.2+ on the other hand provides basically exactly this method here
134-
* luckily it's backwards compatible out of the box.
135-
* tl;dr -> remove after expiration of support for anything below 7.2
136-
*
137-
* @param array $arguments
138-
* @return bool
139-
*/
140-
static protected function evaluateCondition($arguments = null)
141-
{
142-
return (isset($arguments['condition']) && $arguments['condition']);
143-
}
14416
}

Classes/ViewHelpers/Condition/Context/IsBackendViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
12-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1312

1413
/**
1514
* ### Condition: Is context Backend?
@@ -35,9 +34,6 @@
3534
*/
3635
class IsBackendViewHelper extends AbstractConditionViewHelper
3736
{
38-
39-
use ConditionViewHelperTrait;
40-
4137
/**
4238
* @param array $arguments
4339
* @return bool

Classes/ViewHelpers/Condition/Context/IsCliViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
12-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1312

1413
/**
1514
* ### Condition: Is context CLI?
@@ -35,9 +34,6 @@
3534
*/
3635
class IsCliViewHelper extends AbstractConditionViewHelper
3736
{
38-
39-
use ConditionViewHelperTrait;
40-
4137
/**
4238
* @param array $arguments
4339
* @return bool

Classes/ViewHelpers/Condition/Context/IsDevelopmentViewHelper.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use TYPO3\CMS\Core\Utility\GeneralUtility;
1212
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
1313

14-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
15-
1614
/**
1715
* ### Context: IsDevelopment
1816
*
@@ -28,9 +26,6 @@
2826
*/
2927
class IsDevelopmentViewHelper extends AbstractConditionViewHelper
3028
{
31-
32-
use ConditionViewHelperTrait;
33-
3429
/**
3530
* @param array $arguments
3631
* @return bool

Classes/ViewHelpers/Condition/Context/IsFrontendViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
12-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1312

1413
/**
1514
* ### Condition: Is context Frontend?
@@ -35,9 +34,6 @@
3534
*/
3635
class IsFrontendViewHelper extends AbstractConditionViewHelper
3736
{
38-
39-
use ConditionViewHelperTrait;
40-
4137
/**
4238
* @param array $arguments
4339
* @return bool

Classes/ViewHelpers/Condition/Context/IsProductionViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use TYPO3\CMS\Core\Utility\GeneralUtility;
1212
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
13-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1413

1514
/**
1615
* ### Context: IsProduction
@@ -27,9 +26,6 @@
2726
*/
2827
class IsProductionViewHelper extends AbstractConditionViewHelper
2928
{
30-
31-
use ConditionViewHelperTrait;
32-
3329
/**
3430
* @param array $arguments
3531
* @return bool

Classes/ViewHelpers/Condition/Context/IsTestingViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use TYPO3\CMS\Core\Utility\GeneralUtility;
1212
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
13-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1413

1514
/**
1615
* ### Context: IsProduction
@@ -27,9 +26,6 @@
2726
*/
2827
class IsTestingViewHelper extends AbstractConditionViewHelper
2928
{
30-
31-
use ConditionViewHelperTrait;
32-
3329
/**
3430
* @param array $arguments
3531
* @return bool

Classes/ViewHelpers/Condition/Form/HasValidatorViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use TYPO3\CMS\Extbase\Reflection\ReflectionService;
1515
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
1616
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
17-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1817
use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper;
1918

2019
/**
@@ -26,9 +25,6 @@
2625
*/
2726
class HasValidatorViewHelper extends AbstractConditionViewHelper
2827
{
29-
30-
use ConditionViewHelperTrait;
31-
3228
/**
3329
* @var string
3430
*/

Classes/ViewHelpers/Condition/Iterator/ContainsViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
1515
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
1616
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
17-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1817

1918
/**
2019
* Condition ViewHelper. Renders the then-child if Iterator/array
@@ -26,9 +25,6 @@
2625
*/
2726
class ContainsViewHelper extends AbstractConditionViewHelper
2827
{
29-
30-
use ConditionViewHelperTrait;
31-
3228
/**
3329
* Initialize arguments
3430
*/

Classes/ViewHelpers/Condition/Page/HasSubpagesViewHelper.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use TYPO3\CMS\Core\Utility\GeneralUtility;
1313
use TYPO3\CMS\Extbase\Object\ObjectManager;
1414
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
15-
use FluidTYPO3\Vhs\Traits\ConditionViewHelperTrait;
1615

1716
/**
1817
* ### Condition: Page has subpages
@@ -25,9 +24,6 @@
2524
*/
2625
class HasSubpagesViewHelper extends AbstractConditionViewHelper
2726
{
28-
29-
use ConditionViewHelperTrait;
30-
3127
/**
3228
* @var PageService
3329
*/

0 commit comments

Comments
 (0)