[TASK] Makes Uri/TypolinkViewHelper compilable 68/39168/4
authorJan Helke <typo3@helke.de>
Fri, 1 May 2015 18:33:53 +0000 (20:33 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 2 May 2015 18:58:26 +0000 (20:58 +0200)
Resolves: #66717
Releases: master
Change-Id: I55d6e21b0bf474b73f8c51bc07a6f4deaa417b23
Reviewed-on: http://review.typo3.org/39168
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php

index ea42b58..db1c3fb 100644 (file)
@@ -15,7 +15,9 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
  *                                                                        */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 
 /**
@@ -43,7 +45,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
  * </output>
  *
  */
-class TypolinkViewHelper extends AbstractViewHelper {
+class TypolinkViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Render
@@ -54,8 +56,29 @@ class TypolinkViewHelper extends AbstractViewHelper {
         * @return string
         */
        public function render($parameter, $additionalParams = '') {
+               return self::renderStatic(
+                       array(
+                               'parameter' => $parameter,
+                               'additionalParams' => $additionalParams
+                       ),
+                       $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) {
+               $parameter = $arguments['parameter'];
+               $additionalParams = $arguments['additionalParams'];
+
                // Merge the $parameter with other arguments
-               $typolinkParameter = $this->createTypolinkParameterArrayFromArguments($parameter, $additionalParams);
+               $typolinkParameter = self::createTypolinkParameterArrayFromArguments($parameter, $additionalParams);
 
                $content = '';
 
@@ -79,7 +102,7 @@ class TypolinkViewHelper extends AbstractViewHelper {
         *
         * @return array Final merged typolink.parameter as array to be imploded with empty string later
         */
-       protected function createTypolinkParameterArrayFromArguments($parameter, $additionalParameters = '') {
+       static protected function createTypolinkParameterArrayFromArguments($parameter, $additionalParameters = '') {
                // Explode $parameter by whitespace and remove any " around resulting array values
                $parameterArray = GeneralUtility::unQuoteFilenames($parameter, TRUE);