[TASK] Make Format/CDataViewHelper compilable 35/37635/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 8 Mar 2015 13:15:37 +0000 (14:15 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 12 Mar 2015 11:19:25 +0000 (12:19 +0100)
Change-Id: I3a558758f88c32124359b1ec9541266b30047b04
Resolves: #65595
Releases: master
Reviewed-on: http://review.typo3.org/37635
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/fluid/Classes/ViewHelpers/Format/CdataViewHelper.php

index 866421b..63cae2e 100644 (file)
@@ -10,6 +10,10 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+
 /**
  * Outputs an argument/value without any escaping and wraps it with CDATA tags.
  *
@@ -41,7 +45,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *
  * @api
  */
-class CdataViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class CdataViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Disable the escaping interceptor because otherwise the child nodes would be escaped before this view helper
@@ -56,8 +60,24 @@ class CdataViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
         * @return string
         */
        public function render($value = NULL) {
+               return self::renderStatic(
+                       array('value' => $value),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $value = $arguments['value'];
                if ($value === NULL) {
-                       $value = $this->renderChildren();
+                       $value = $renderChildrenClosure();
                }
                return sprintf('<![CDATA[%s]]>', $value);
        }