[!!!][TASK] Remove deprecated f:switch and f:case 15/52915/5
authorClaus Due <claus@namelesscoder.net>
Mon, 22 May 2017 19:02:48 +0000 (21:02 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 1 Jun 2017 20:51:56 +0000 (22:51 +0200)
Counterparts exist in Fluid engine.

Change-Id: I7fd0bc3b5569196858a8f5aa6967de2bf76385b1
Resolves: #81307
Resolves: #81106
Releases: master
Reviewed-on: https://review.typo3.org/52915
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Documentation/Changelog/master/Breaking-80700-DeprecatedFunctionalityRemoved.rst
typo3/sysext/fluid/Classes/ViewHelpers/CaseViewHelper.php [deleted file]
typo3/sysext/fluid/Classes/ViewHelpers/SwitchViewHelper.php [deleted file]

index 3e34351..1042ea8 100644 (file)
@@ -24,12 +24,15 @@ The following PHP classes that have been previously deprecated for v8 have been
 * TYPO3\CMS\Core\Messaging\ErrorpageMessage
 * TYPO3\CMS\Core\TimeTracker\NullTimeTracker
 * TYPO3\CMS\Extbase\Utility\ArrayUtility
+* TYPO3\CMS\Fluid\ViewHelpers\CaseViewHelper
+* TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper
 * TYPO3\CMS\Form\Domain\Model\FormElements\AdvancedPassword
 * TYPO3\CMS\Form\ViewHelpers\Form\CheckboxViewHelper
 * TYPO3\CMS\Form\ViewHelpers\Form\PlainTextMailViewHelper
 * TYPO3\CMS\Frontend\Page\FramesetRenderer
 * TYPO3\CMS\Lowlevel\CleanerCommand
 
+
 The following PHP interfaces have been dropped:
 * TYPO3\CMS\Backend\Form\DatabaseFileIconsHookInterface
 
@@ -352,6 +355,7 @@ The following Fluid ViewHelper arguments have been removed:
 * f:be.pageRenderer->enableExtJsDebug
 * f:be.pageRenderer->loadJQuery
 * f:be.pageRenderer->jQueryNamespace
+* f:case->default (use f:defaultCase instead)
 
 The following requireJS modules have been removed:
 * TYPO3/CMS/Core/QueryGenerator
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/CaseViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/CaseViewHelper.php
deleted file mode 100644 (file)
index 867b357..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-namespace TYPO3\CMS\Fluid\ViewHelpers;
-
-/*                                                                        *
- * This script is backported from the TYPO3 Flow package "TYPO3.Fluid".   *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License, either version 3   *
- *  of the License, or (at your option) any later version.                *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3\CMS\Fluid\Core\ViewHelper\Exception;
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\ViewHelpers\SwitchViewHelper as OriginalSwitchViewHelper;
-
-/**
- * Case view helper that is only usable within the SwitchViewHelper.
- * @see \TYPO3\CMS\Fluid\ViewHelpers\SwitchViewHelper
- *
- * @api
- */
-class CaseViewHelper extends AbstractViewHelper
-{
-    /**
-     * @var bool
-     */
-    protected $escapeOutput = false;
-
-    /**
-     * Initialize ViewHelper arguments
-     */
-    public function initializeArguments()
-    {
-        $this->registerArgument('value', 'mixed', 'The switch value. If it matches, the child will be rendered.', false, null);
-        $this->registerArgument('default', 'bool', 'If this is set, this child will be rendered, if none else matches.', false, false);
-    }
-
-    /***
-     * @return string the contents of this view helper if $value equals the expression of the surrounding switch view helper, or $default is TRUE. otherwise an empty string
-     * @throws Exception
-     *
-     * @api
-     */
-    public function render()
-    {
-        return static::renderStatic(
-            [
-                'value' => $this->arguments['value'],
-                'default' => $this->arguments['default']
-            ],
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
-    }
-
-    /**
-     * @param array $arguments
-     * @param \Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     *
-     * @return mixed|string
-     * @throws Exception
-     */
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
-    {
-        $value = $arguments['value'];
-        $default = (bool)$arguments['default'];
-        $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
-        if ($default !== false) {
-            GeneralUtility::logDeprecatedViewHelperAttribute(
-                'default',
-                $renderingContext,
-                'Argument "default" on f:case is deprecated - use f:defaultCase instead'
-            );
-        }
-        if ($value === null && $default === false) {
-            throw new Exception('The case View helper must have either value or default argument', 1382867521);
-        }
-        $expression = $viewHelperVariableContainer->get(OriginalSwitchViewHelper::class, 'switchExpression');
-
-        // non-type-safe comparison by intention
-        if ($default === true || $expression == $value) {
-            $viewHelperVariableContainer->addOrUpdate(OriginalSwitchViewHelper::class, 'break', true);
-            return $renderChildrenClosure();
-        }
-
-        return '';
-    }
-}
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/SwitchViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/SwitchViewHelper.php
deleted file mode 100644 (file)
index 79ff761..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-namespace TYPO3\CMS\Fluid\ViewHelpers;
-
-/*                                                                        *
- * This script is backported from the TYPO3 Flow package "TYPO3.Fluid".   *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License, either version 3   *
- *  of the License, or (at your option) any later version.                *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-use TYPO3Fluid\Fluid\Core\Compiler\StopCompilingException;
-use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
-use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\NodeInterface;
-use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
-use TYPO3Fluid\Fluid\ViewHelpers\CaseViewHelper as OriginalCaseViewHelper;
-use TYPO3Fluid\Fluid\ViewHelpers\DefaultCaseViewHelper;
-
-/**
- * Switch view helper which can be used to render content depending on a value or expression.
- * Implements what a basic switch()-PHP-method does.
- *
- * = Examples =
- *
- * <code title="Simple Switch statement">
- * <f:switch expression="{person.gender}">
- *   <f:case value="male">Mr.</f:case>
- *   <f:case value="female">Mrs.</f:case>
- *   <f:defaultCase>Mrs. or Mr.</f:defaultCase>
- * </f:switch>
- * </code>
- * <output>
- * Mr. / Mrs. (depending on the value of {person.gender}) or if no value evaluates to TRUE, defaultCase
- * </output>
- *
- * Note: Using this view helper can be a sign of weak architecture. If you end up using it extensively
- * you might want to consider restructuring your controllers/actions and/or use partials and sections.
- * E.g. the above example could be achieved with <f:render partial="title.{person.gender}" /> and the partials
- * "title.male.html", "title.female.html", ...
- * Depending on the scenario this can be easier to extend and possibly contains less duplication.
- *
- * @api
- */
-class SwitchViewHelper extends \TYPO3Fluid\Fluid\ViewHelpers\SwitchViewHelper
-{
-    /**
-     * @param NodeInterface $node
-     * @return bool
-     */
-    protected function isDefaultCaseNode(NodeInterface $node)
-    {
-        if ($node instanceof ViewHelperNode) {
-            $viewHelperClassName = $node->getViewHelperClassName();
-            $arguments = $node->getArguments();
-            return
-                $viewHelperClassName === DefaultCaseViewHelper::class ||
-                (
-                    $viewHelperClassName === CaseViewHelper::class && isset($arguments['default']) && $arguments['default']
-                )
-            ;
-        }
-        return false;
-    }
-
-    /**
-     * @param NodeInterface $node
-     * @return bool
-     */
-    protected function isCaseNode(NodeInterface $node)
-    {
-        if ($node instanceof ViewHelperNode) {
-            $viewHelperClassName = $node->getViewHelperClassName();
-            return $viewHelperClassName === CaseViewHelper::class || $viewHelperClassName === OriginalCaseViewHelper::class;
-        }
-        return false;
-    }
-
-    /**
-     * @param string $argumentsName
-     * @param string $closureName
-     * @param string $initializationPhpCode
-     * @param ViewHelperNode $node
-     * @param TemplateCompiler $compiler
-     */
-    public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
-    {
-        if (count($node->getChildNodes())) {
-            throw new StopCompilingException('switch view helper', 1476122366);
-        }
-    }
-}