[TASK] Make HtmlspecialcharsViewHelper compilable 67/39167/3
authordirk_juettner <dirk.juettner@gmail.com>
Fri, 1 May 2015 18:26:31 +0000 (20:26 +0200)
committerFrank Nägler <typo3@naegler.net>
Fri, 1 May 2015 20:16:44 +0000 (22:16 +0200)
Resolves: #66711
Releases: master
Change-Id: Ie2954aafe8c2f087709ece7fb3c128f656bcbf9c
Reviewed-on: http://review.typo3.org/39167
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlspecialcharsViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/HtmlspecialcharsViewHelperTest.php

index 95894a5..8add216 100644 (file)
@@ -35,5 +35,4 @@ abstract class AbstractEncodingViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
                }
                return self::$defaultEncoding;
        }
-
-}
+}
\ No newline at end of file
index 54c6d2e..9903861 100644 (file)
@@ -11,6 +11,8 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+
 
 /**
  * Applies htmlspecialchars() escaping to a value
@@ -56,8 +58,31 @@ class HtmlspecialcharsViewHelper extends AbstractEncodingViewHelper implements C
         * @api
         */
        public function render($value = NULL, $keepQuotes = FALSE, $encoding = NULL, $doubleEncode = TRUE) {
+               return self::renderStatic(
+                       array(
+                               'value' => $value,
+                               'keepQuotes' => $keepQuotes,
+                               'encoding' => $encoding,
+                               'doubleEncode' => $doubleEncode
+                       ),
+                       $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'];
+               $keepQuotes = $arguments['keepQuotes'];
+               $encoding = $arguments['encoding'];
+               $doubleEncode = $arguments['doubleEncode'];
                if ($value === NULL) {
-                       $value = $this->renderChildren();
+                       $value = $renderChildrenClosure();
                }
                if (!is_string($value)) {
                        return $value;
@@ -88,4 +113,4 @@ class HtmlspecialcharsViewHelper extends AbstractEncodingViewHelper implements C
                                $valueVariableName, $valueVariableName, $valueVariableName, $argumentsVariableName, $argumentsVariableName, $argumentsVariableName, $argumentsVariableName);
        }
 
-}
+}
\ No newline at end of file
index 392c1af..2464db3 100644 (file)
@@ -10,19 +10,25 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
+use TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper;
+use TYPO3\CMS\Core\Tests\UnitTestCase;
 
 /**
  * Test case
  */
-class HtmlspecialcharsViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class HtmlspecialcharsViewHelperTest extends UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper
+        * @var HtmlspecialcharsViewHelper
         */
        protected $viewHelper;
 
        protected function setUp() {
-               $this->viewHelper = $this->getMock(\TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper::class, array('renderChildren'));
+               $this->viewHelper = $this->getMock(HtmlspecialcharsViewHelper::class, array('renderChildren'));
+               /** @var RenderingContext $renderingContext */
+               $renderingContext = $this->getMock(RenderingContext::class);
+               $this->viewHelper->setRenderingContext($renderingContext);
        }
 
        /**
@@ -118,4 +124,4 @@ class HtmlspecialcharsViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $this->assertSame($source, $actualResult);
        }
 
-}
+}
\ No newline at end of file