[TASK] Make ModuleLinkViewHelper compilable 03/39203/3
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 2 May 2015 16:14:15 +0000 (18:14 +0200)
committerFrank Nägler <typo3@naegler.net>
Sat, 2 May 2015 19:41:00 +0000 (21:41 +0200)
Resolves: #66752
Releases: master
Change-Id: I974515fb8be762ef7105171956e1e7d053111a4e
Reviewed-on: http://review.typo3.org/39203
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/scheduler/Classes/ViewHelpers/ModuleLinkViewHelper.php

index 984b02b..bdd8a75 100644 (file)
@@ -15,13 +15,15 @@ namespace TYPO3\CMS\Scheduler\ViewHelpers;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
 
 /**
  * Create internal link within backend app
  * @internal
  */
 
 /**
  * Create internal link within backend app
  * @internal
  */
-class ModuleLinkViewHelper extends AbstractViewHelper {
+class ModuleLinkViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Render module link with command and arguments
 
        /**
         * Render module link with command and arguments
@@ -32,11 +34,30 @@ class ModuleLinkViewHelper extends AbstractViewHelper {
         * @return string
         */
        public function render($controller, $action, array $arguments = array()) {
         * @return string
         */
        public function render($controller, $action, array $arguments = array()) {
+               return self::renderStatic(
+                       array(
+                               'controller' => $controller,
+                               'action' => $action,
+                               'arguments' => $arguments,
+                       ),
+                       $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) {
                $moduleArguments = array();
                $moduleArguments = array();
-               $moduleArguments['SET']['function'] = $controller;
-               $moduleArguments['CMD'] = $action;
-               if (!empty($arguments)) {
-                       $moduleArguments['tx_scheduler'] = $arguments;
+               $moduleArguments['SET']['function'] = $arguments['controller'];
+               $moduleArguments['CMD'] = $arguments['action'];
+               if (!empty($arguments['arguments'])) {
+                       $moduleArguments['tx_scheduler'] = $arguments['arguments'];
                }
 
                return BackendUtility::getModuleUrl('system_txschedulerM1', $moduleArguments);
                }
 
                return BackendUtility::getModuleUrl('system_txschedulerM1', $moduleArguments);