[BUGFIX] Implement CMS setRenderingContext for AbstractConditionViewHelper 52/50352/3
authorClaus Due <claus@namelesscoder.net>
Mon, 24 Oct 2016 22:18:01 +0000 (00:18 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 25 Oct 2016 14:30:34 +0000 (16:30 +0200)
This fixes an issue where the CMS specific overridden
setRenderingContext method on CMS AbstractConditionViewHelper is
not present because the class does not subclass the CMS
AbstractViewHelper (due to coupling concerns). Subsequently the
ControllerContext is not assigned in $this->controllerContext.

This inconsistency is fixed by adding the method just like it
appears in the AbstractViewHelper class, along with declaring
the property containing the ControllerContext.

Change-Id: I74779c47e8077d727a8a18c0e00696ba265f3c7a
Resolves: #78414
Releases: 8.4, master
Reviewed-on: https://review.typo3.org/50352
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frederic Gaus <frederic.gaus@flagbit.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractConditionViewHelper.php

index 7d13c0d..e3eb376 100644 (file)
@@ -20,6 +20,14 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper;
 abstract class AbstractConditionViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper
 {
     /**
+     * Controller Context to use
+     *
+     * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
+     * @api
+     */
+    protected $controllerContext;
+
+    /**
      * Renders <f:then> child if $condition is true, otherwise renders <f:else> child.
      *
      * @param bool $condition View helper condition
@@ -34,4 +42,16 @@ abstract class AbstractConditionViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHe
             return $this->renderElseChild();
         }
     }
+
+    /**
+     * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
+     * @return void
+     */
+    public function setRenderingContext(\TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
+    {
+        parent::setRenderingContext($renderingContext);
+        if ($renderingContext instanceof \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext) {
+            $this->controllerContext = $renderingContext->getControllerContext();
+        }
+    }
 }