Revert "[TASK] Make \Be\Menus\ActionMenuItemViewHelper compilable" 99/39499/3
authorFrank Nägler <typo3@naegler.net>
Tue, 12 May 2015 14:52:03 +0000 (16:52 +0200)
committerFrank Nägler <typo3@naegler.net>
Tue, 12 May 2015 14:59:45 +0000 (16:59 +0200)
This reverts commit 9695759844f2c4981339aff77be50340f8c6b1b6.

Reason for the revert is that initialize() of the abstract is no
longer called, which takes care of "additionalAttributes" and
"data-" attributes. The introduced getTagBuilder() method is not
sufficient. So, basically the rule "no simple migration to compilable
possible if the VH keeps local state" was violated here.

Change-Id: Ie32bf34f3f230b4fa6c4dafa636ab5e18f400536
Releases: master
Resolves: #66898
Reverts: #66751
Reviewed-on: http://review.typo3.org/39499
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php

index d08a2a2..5e80f6c 100644 (file)
@@ -122,13 +122,4 @@ abstract class AbstractTagBasedViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
                $this->registerTagAttribute('onclick', 'string', 'JavaScript evaluated for the onclick event');
        }
 
-       /**
-        * Get the TagBuilder for renderStatic function
-        *
-        * @return TagBuilder
-        */
-       protected static function getTagBuilder(){
-               return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TagBuilder::class);
-       }
-
 }
index bdecb57..b2e939a 100644 (file)
@@ -20,11 +20,6 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Menus;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
-
-use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
-use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
-
 /**
  * View helper which returns a option tag.
  * This view helper only works in conjunction with \TYPO3\CMS\Fluid\ViewHelpers\Be\Menus\ActionMenuViewHelper
@@ -53,7 +48,12 @@ use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
  * localized selectbox
  * <output>
  */
-class ActionMenuItemViewHelper extends AbstractTagBasedViewHelper implements CompilableInterface {
+class ActionMenuItemViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'option';
 
        /**
         * Renders an ActionMenu option tag
@@ -61,53 +61,22 @@ class ActionMenuItemViewHelper extends AbstractTagBasedViewHelper implements Com
         * @param string $label label of the option tag
         * @param string $controller controller to be associated with this ActionMenuItem
         * @param string $action the action to be associated with this ActionMenuItem
-        * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is
-        *     selected
+        * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is selected
         * @return string the rendered option tag
         * @see \TYPO3\CMS\Fluid\ViewHelpers\Be\Menus\ActionMenuViewHelper
         */
        public function render($label, $controller, $action, array $arguments = array()) {
-               return self::renderStatic(
-                       array(
-                               'label' => $label,
-                               'controller' => $controller,
-                               'action' => $action,
-                               'arguments' => $arguments
-                       ),
-                       $this->buildRenderChildrenClosure(),
-                       $this->renderingContext
-               );
-       }
-
-       /**
-        * Render static for more speed in fluid
-        *
-        * @param array $arguments
-        * @param callable $renderChildrenClosure
-        * @param RenderingContextInterface $renderingContext
-        * @return string
-        */
-       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
-               $label = $arguments['label'];
-               $controller = $arguments['controller'];
-               $action = $arguments['action'];
-               $arguments = $arguments['arguments'];
-
-               $tag = static::getTagBuilder();
-               $tag->setTagName('option');
-               $uriBuilder = $renderingContext->getControllerContext()->getUriBuilder();
+               $uriBuilder = $this->controllerContext->getUriBuilder();
                $uri = $uriBuilder->reset()->uriFor($action, $arguments, $controller);
-
-               $tag->addAttribute('value', $uri);
-               $currentRequest = $renderingContext->getControllerContext()->getRequest();
+               $this->tag->addAttribute('value', $uri);
+               $currentRequest = $this->controllerContext->getRequest();
                $currentController = $currentRequest->getControllerName();
                $currentAction = $currentRequest->getControllerActionName();
                if ($action === $currentAction && $controller === $currentController) {
-                       $tag->addAttribute('selected', 'selected');
+                       $this->tag->addAttribute('selected', 'selected');
                }
-               $tag->setContent($label);
-               return $tag->render();
+               $this->tag->setContent($label);
+               return $this->tag->render();
        }
 
-
 }