[TASK] Remove extended fluid core class CmsVariableProvider 27/53227/4
authorBenni Mack <benni@typo3.org>
Thu, 15 Jun 2017 20:28:16 +0000 (22:28 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 29 Aug 2017 20:35:46 +0000 (22:35 +0200)
The CmsVariableProvider within EXT:fluid extends a Fluid core class with
the same functionality and can be removed. A class alias ensures that the
PHP class is still available.

Resolves: #82229
Releases: master
Change-Id: I71eb7beaf0684631d9c7e857bbed91f08b75d47c
Reviewed-on: https://review.typo3.org/53227
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Claus Due <claus@phpmind.net>
Tested-by: Claus Due <claus@phpmind.net>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Documentation/Changelog/master/Important-82229-FluidImplementationOfCmsVariableProviderRemoved.rst [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php
typo3/sysext/fluid/Classes/Core/Variables/CmsVariableProvider.php [deleted file]
typo3/sysext/fluid/Migrations/Code/ClassAliasMap.php
typo3/sysext/fluid/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-82229-FluidImplementationOfCmsVariableProviderRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-82229-FluidImplementationOfCmsVariableProviderRemoved.rst
new file mode 100644 (file)
index 0000000..fd02497
--- /dev/null
@@ -0,0 +1,19 @@
+.. include:: ../../Includes.txt
+
+=======================================================================
+Important: #82229 - Fluid implementation of CmsVariableProvider removed
+=======================================================================
+
+See :issue:`82229`
+
+Description
+===========
+
+The PHP class within EXT:fluid named :php:`CmsVariableProvider` was removed. The custom functionality
+is available in its parent class :php:`TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider` from
+Fluid standalone can be implemented directly.
+
+Instantiating the removed class will still work through the functionality of class aliases in PHP,
+however, using the parent class is encouraged.
+
+.. index:: Fluid, PHP-API, FullyScanned
index ffc27cc..8164630 100644 (file)
@@ -19,7 +19,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
 use TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface;
-use TYPO3\CMS\Fluid\Core\Variables\CmsVariableProvider;
 use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
 use TYPO3\CMS\Fluid\View\TemplatePaths;
 use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
@@ -28,6 +27,7 @@ use TYPO3Fluid\Fluid\Core\Parser\TemplateParser;
 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\EscapingModifierTemplateProcessor;
 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\NamespaceDetectionTemplateProcessor;
 use TYPO3Fluid\Fluid\Core\Parser\TemplateProcessor\PassthroughSourceModifierTemplateProcessor;
+use TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider;
 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker;
 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
 use TYPO3Fluid\Fluid\View\ViewInterface;
@@ -38,13 +38,6 @@ use TYPO3Fluid\Fluid\View\ViewInterface;
 class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
 {
     /**
-     * Template Variable Container. Contains all variables available through object accessors in the template
-     *
-     * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer
-     */
-    protected $templateVariableContainer;
-
-    /**
      * Controller context being passed to the ViewHelper
      *
      * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
@@ -76,6 +69,7 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
             $this->setTemplateCompiler(new TemplateCompiler());
             $this->setViewHelperInvoker(new ViewHelperInvoker());
             $this->setViewHelperVariableContainer(new ViewHelperVariableContainer());
+            $this->setVariableProvider(new StandardVariableProvider());
             $this->setTemplateProcessors(
                 [
                     new EscapingModifierTemplateProcessor(),
@@ -88,7 +82,6 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
         $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
         $this->setTemplatePaths($objectManager->get(TemplatePaths::class));
         $this->setViewHelperResolver($objectManager->get(ViewHelperResolver::class));
-        $this->setVariableProvider($objectManager->get(CmsVariableProvider::class));
 
         /** @var FluidTemplateCache $cache */
         $cache = $objectManager->get(CacheManager::class)->getCache('fluid_template');
diff --git a/typo3/sysext/fluid/Classes/Core/Variables/CmsVariableProvider.php b/typo3/sysext/fluid/Classes/Core/Variables/CmsVariableProvider.php
deleted file mode 100644 (file)
index 1f005c9..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-namespace TYPO3\CMS\Fluid\Core\Variables;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Class CmsVariableProvider
- */
-class CmsVariableProvider extends \TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider
-{
-    /**
-     * Get a variable by dotted path expression, retrieving the
-     * variable from nested arrays/objects one segment at a time.
-     * If the second argument is provided, it must be an array of
-     * accessor names which can be used to extract each value in
-     * the dotted path.
-     *
-     * @param string $path
-     * @param array $accessors
-     * @return mixed
-     */
-    public function getByPath($path, array $accessors = [])
-    {
-        $path = $this->resolveSubVariableReferences($path);
-        return \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyPath($this->variables, $path);
-    }
-
-    /**
-     * @param string $propertyPath
-     * @return string
-     */
-    protected function resolveSubVariableReferences($propertyPath)
-    {
-        if (strpos($propertyPath, '{') !== false) {
-            preg_match_all('/(\{.*\})/', $propertyPath, $matches);
-            foreach ($matches[1] as $match) {
-                $subPropertyPath = substr($match, 1, -1);
-                $propertyPath = str_replace($match, $this->getByPath($subPropertyPath), $propertyPath);
-            }
-        }
-        return $propertyPath;
-    }
-}
index aab9d5b..c089882 100644 (file)
@@ -23,6 +23,7 @@ return [
     'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode' => \TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class,
     'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer' => \TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider::class,
     'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer' => \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer::class,
+    'TYPO3\\CMS\\Fluid\\Core\\Variables\\CmsVariableProvider' => \TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider::class,
 
     // Semi API level classes; mainly used in unit tests
     'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder' => \TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder::class
index 57c0daa..13005c4 100644 (file)
@@ -80,6 +80,12 @@ namespace TYPO3\CMS\Fluid\Core\Compiler {
     }
 }
 
+namespace TYPO3\CMS\Fluid\Core\Variables {
+    class CmsVariableProvider extends \TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider
+    {
+    }
+}
+
 namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree {
     class RootNode extends \TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\RootNode
     {
index ccaa22d..5e07e23 100644 (file)
@@ -344,6 +344,11 @@ return [
             'Breaking-82148-DownloadSQLDumpDroppedInEM.rst',
         ],
     ],
+    'TYPO3\CMS\Fluid\Core\Variables\CmsVariableProvider' => [
+        'restFiles' => [
+            'Important-82229-FluidImplementationOfCmsVariableProviderRemoved.rst',
+        ],
+    ],
 
     // Removed interfaces
     'TYPO3\CMS\Backend\Form\DatabaseFileIconsHookInterface' => [