[TASK] Rename TypoScriptReferenceLoader to TypoScriptReferenceController 10/56310/7
authorMathias Brodala <mbrodala@pagemachine.de>
Sat, 17 Mar 2018 14:25:00 +0000 (15:25 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 17:09:14 +0000 (18:09 +0100)
Change-Id: I31fcc83c20766aacd3af7d8b68df9469d3db13dc
Resolves: #84411
Releases: master
Reviewed-on: https://review.typo3.org/56310
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-84411-TypoScriptReferenceLoaderRenamedToTypoScriptReferenceController.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
typo3/sysext/t3editor/Classes/Controller/TypoScriptReferenceController.php [new file with mode: 0644]
typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php [deleted file]
typo3/sysext/t3editor/Configuration/Backend/AjaxRoutes.php
typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php
typo3/sysext/t3editor/Migrations/Code/LegacyClassesForIde.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84411-TypoScriptReferenceLoaderRenamedToTypoScriptReferenceController.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84411-TypoScriptReferenceLoaderRenamedToTypoScriptReferenceController.rst
new file mode 100644 (file)
index 0000000..28d3528
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+========================================================================================
+Deprecation: #84411 - TypoScriptReferenceLoader renamed to TypoScriptReferenceController
+========================================================================================
+
+See :issue:`84411`
+
+Description
+===========
+
+The PHP class :php:`TYPO3\CMS\T3editor\TypoScriptReferenceLoader` has been renamed to
+:php:`TYPO3\CMS\T3editor\Controller\TypoScriptReferenceController`.
+
+
+Impact
+======
+
+The old class name has been registered as class alias and will still work.
+Old class name usage however is discouraged and should be avoided, the
+alias will vanish with core version 10.
+
+
+Affected Installations
+======================
+
+Extensions which use the old class name are affected. The extension scanner will find affected extensions using the old class name.
+
+
+Migration
+=========
+
+Use new class name instead.
+
+.. index:: Backend, PHP-API, FullyScanned, ext:t3editor
\ No newline at end of file
index 61dfed7..f4288c1 100644 (file)
@@ -669,4 +669,9 @@ return [
             'Deprecation-84409-ImageManipulationWizardRenamedToImageManipulationController.rst',
         ],
     ],
+    'TYPO3\CMS\T3editor\TypoScriptReferenceLoader' => [
+        'restFiles' => [
+            'Deprecation-84411-TypoScriptReferenceLoaderRenamedToTypoScriptReferenceController.rst',
+        ],
+    ],
 ];
diff --git a/typo3/sysext/t3editor/Classes/Controller/TypoScriptReferenceController.php b/typo3/sysext/t3editor/Classes/Controller/TypoScriptReferenceController.php
new file mode 100644 (file)
index 0000000..5cd9cea
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+namespace TYPO3\CMS\T3editor\Controller;
+
+/*
+ * 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!
+ */
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Http\JsonResponse;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Loads TSref information from a XML file an responds to an AJAX call.
+ */
+class TypoScriptReferenceController
+{
+    /**
+     * @var \DOMDocument
+     */
+    protected $xmlDoc;
+
+    /**
+     * Default constructor
+     */
+    public function __construct()
+    {
+        $GLOBALS['LANG']->includeLLFile('EXT:t3editor/Resources/Private/Language/locallang.xlf');
+    }
+
+    /**
+     * Load TypoScript reference
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     */
+    public function loadReference(ServerRequestInterface $request): ResponseInterface
+    {
+        // Load the TSref XML information:
+        $this->loadFile(GeneralUtility::getFileAbsFileName('EXT:t3editor/Resources/Private/tsref.xml'));
+        return (new JsonResponse())->setPayload($this->getTypes());
+    }
+
+    /**
+     * Load XML file
+     *
+     * @param string $filepath
+     */
+    protected function loadFile($filepath)
+    {
+        // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
+        $previousValueOfEntityLoader = libxml_disable_entity_loader();
+        $this->xmlDoc = new \DOMDocument('1.0', 'utf-8');
+        $this->xmlDoc->loadXML(file_get_contents($filepath));
+        libxml_disable_entity_loader($previousValueOfEntityLoader);
+        // @TODO: oliver@typo3.org: I guess this is not required here
+        $this->xmlDoc->saveXML();
+    }
+
+    /**
+     * Get types from XML
+     *
+     * @return array
+     */
+    protected function getTypes() : array
+    {
+        $types = $this->xmlDoc->getElementsByTagName('type');
+        $typeArr = [];
+        foreach ($types as $type) {
+            $typeId = $type->getAttribute('id');
+            $typeName = $type->getAttribute('name');
+            if (!$typeName) {
+                $typeName = $typeId;
+            }
+            $properties = $type->getElementsByTagName('property');
+            $propArr = [];
+            foreach ($properties as $property) {
+                $p = [];
+                $p['name'] = $property->getAttribute('name');
+                $p['type'] = $property->getAttribute('type');
+                $propArr[$property->getAttribute('name')] = $p;
+            }
+            $typeArr[$typeId] = [];
+            $typeArr[$typeId]['properties'] = $propArr;
+            $typeArr[$typeId]['name'] = $typeName;
+            if ($type->hasAttribute('extends')) {
+                $typeArr[$typeId]['extends'] = $type->getAttribute('extends');
+            }
+        }
+        return $typeArr;
+    }
+}
diff --git a/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php b/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php
deleted file mode 100644 (file)
index ceec7d6..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-namespace TYPO3\CMS\T3editor;
-
-/*
- * 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!
- */
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use TYPO3\CMS\Core\Http\JsonResponse;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Loads TSref information from a XML file an responds to an AJAX call.
- */
-class TypoScriptReferenceLoader
-{
-    /**
-     * @var \DOMDocument
-     */
-    protected $xmlDoc;
-
-    /**
-     * Default constructor
-     */
-    public function __construct()
-    {
-        $GLOBALS['LANG']->includeLLFile('EXT:t3editor/Resources/Private/Language/locallang.xlf');
-    }
-
-    /**
-     * General processor for AJAX requests.
-     * Called by AjaxRequestHandler
-     *
-     * @param ServerRequestInterface $request
-     * @return ResponseInterface
-     */
-    public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface
-    {
-        // Load the TSref XML information:
-        $this->loadFile(GeneralUtility::getFileAbsFileName('EXT:t3editor/Resources/Private/tsref.xml'));
-        return (new JsonResponse())->setPayload($this->getTypes());
-    }
-
-    /**
-     * Load XML file
-     *
-     * @param string $filepath
-     */
-    protected function loadFile($filepath)
-    {
-        // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
-        $previousValueOfEntityLoader = libxml_disable_entity_loader();
-        $this->xmlDoc = new \DOMDocument('1.0', 'utf-8');
-        $this->xmlDoc->loadXML(file_get_contents($filepath));
-        libxml_disable_entity_loader($previousValueOfEntityLoader);
-        // @TODO: oliver@typo3.org: I guess this is not required here
-        $this->xmlDoc->saveXML();
-    }
-
-    /**
-     * Get types from XML
-     *
-     * @return array
-     */
-    protected function getTypes() : array
-    {
-        $types = $this->xmlDoc->getElementsByTagName('type');
-        $typeArr = [];
-        foreach ($types as $type) {
-            $typeId = $type->getAttribute('id');
-            $typeName = $type->getAttribute('name');
-            if (!$typeName) {
-                $typeName = $typeId;
-            }
-            $properties = $type->getElementsByTagName('property');
-            $propArr = [];
-            foreach ($properties as $property) {
-                $p = [];
-                $p['name'] = $property->getAttribute('name');
-                $p['type'] = $property->getAttribute('type');
-                $propArr[$property->getAttribute('name')] = $p;
-            }
-            $typeArr[$typeId] = [];
-            $typeArr[$typeId]['properties'] = $propArr;
-            $typeArr[$typeId]['name'] = $typeName;
-            if ($type->hasAttribute('extends')) {
-                $typeArr[$typeId]['extends'] = $type->getAttribute('extends');
-            }
-        }
-        return $typeArr;
-    }
-}
index 7a0f00c..64283fe 100644 (file)
@@ -7,7 +7,7 @@ return [
     // Get TSRef
     't3editor_tsref' => [
         'path' => '/t3editor/tsref',
-        'target' => \TYPO3\CMS\T3editor\TypoScriptReferenceLoader::class . '::processAjaxRequest'
+        'target' => \TYPO3\CMS\T3editor\Controller\TypoScriptReferenceController::class . '::loadReference'
     ],
 
     // Load code completion templates
index d8e5c23..9483d2a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
 return [
     'TYPO3\\CMS\\T3editor\\CodeCompletion' => \TYPO3\CMS\T3editor\Controller\CodeCompletionController::class,
+    'TYPO3\\CMS\\T3editor\\TypoScriptReferenceLoader' => \TYPO3\CMS\T3editor\Controller\TypoScriptReferenceController::class,
 ];
index 44cfd02..d8b41e8 100644 (file)
@@ -10,4 +10,11 @@ namespace TYPO3\CMS\T3editor {
     class CodeCompletion extends \TYPO3\CMS\T3editor\Controller\CodeCompletionController
     {
     }
+
+    /**
+     * @deprecated since v9, will be removed in v10
+     */
+    class TypoScriptReferenceLoader extends \TYPO3\CMS\T3editor\Controller\TypoScriptReferenceController
+    {
+    }
 }