From ac1844ef55beb8089ae57e34ffcc1a15616f36db Mon Sep 17 00:00:00 2001
From: Mathias Brodala <mbrodala@pagemachine.de>
Date: Sat, 17 Mar 2018 15:36:21 +0100
Subject: [PATCH] [TASK] Rename CodeCompletion to CodeCompletionController

Change-Id: Ia913d08b832f27250a0def2cc1b6873210a1d8a6
Resolves: #84410
Releases: master
Reviewed-on: https://review.typo3.org/56312
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 composer.json                                 |  1 +
 composer.lock                                 |  2 +-
 ...etionRenamedToCodeCompletionController.rst | 35 +++++++++++++++++++
 .../ExtensionScanner/Php/ClassNameMatcher.php |  5 +++
 .../CodeCompletionController.php}             |  6 ++--
 .../Configuration/Backend/AjaxRoutes.php      |  2 +-
 .../Migrations/Code/ClassAliasMap.php         |  4 +++
 .../Migrations/Code/LegacyClassesForIde.php   | 13 +++++++
 typo3/sysext/t3editor/composer.json           |  5 +++
 9 files changed, 68 insertions(+), 5 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-84410-CodeCompletionRenamedToCodeCompletionController.rst
 rename typo3/sysext/t3editor/Classes/{CodeCompletion.php => Controller/CodeCompletionController.php} (96%)
 create mode 100644 typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php
 create mode 100644 typo3/sysext/t3editor/Migrations/Code/LegacyClassesForIde.php

diff --git a/composer.json b/composer.json
index a0c100488233..bb55b82024ef 100644
--- a/composer.json
+++ b/composer.json
@@ -89,6 +89,7 @@
 				"typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/reports/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/saltedpasswords/Migrations/Code/ClassAliasMap.php",
+				"typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php",
 				"typo3/sysext/workspaces/Migrations/Code/ClassAliasMap.php"
 			]
 		},
diff --git a/composer.lock b/composer.lock
index 898274f867e4..bced5a14decf 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "33161a8bc06421b8de725e3dfb422fae",
+    "content-hash": "9e7e4b2f0374c71e482a335873a428aa",
     "packages": [
         {
             "name": "cogpowered/finediff",
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84410-CodeCompletionRenamedToCodeCompletionController.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84410-CodeCompletionRenamedToCodeCompletionController.rst
new file mode 100644
index 000000000000..2644cd040b78
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84410-CodeCompletionRenamedToCodeCompletionController.rst
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+========================================================================
+Deprecation: #84410 - CodeCompletion renamed to CodeCompletionController
+========================================================================
+
+See :issue:`84410`
+
+Description
+===========
+
+The PHP class :php:`TYPO3\CMS\T3editor\CodeCompletion` has been renamed to
+:php:`TYPO3\CMS\T3editor\Controller\CodeCompletionController`.
+
+
+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 since, 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
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
index 5ac17f7bfcd2..a2f024d42433 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
@@ -659,4 +659,9 @@ return [
             'Deprecation-84399-ClassRecordListRenamedToRecordListController.rst',
         ],
     ],
+    'TYPO3\CMS\T3editor\CodeCompletion' => [
+        'restFiles' => [
+            'Deprecation-84410-CodeCompletionRenamedToCodeCompletionController.rst',
+        ],
+    ],
 ];
diff --git a/typo3/sysext/t3editor/Classes/CodeCompletion.php b/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
similarity index 96%
rename from typo3/sysext/t3editor/Classes/CodeCompletion.php
rename to typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
index 5770cb21df24..a9e9980d8af1 100644
--- a/typo3/sysext/t3editor/Classes/CodeCompletion.php
+++ b/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
@@ -1,5 +1,5 @@
 <?php
-namespace TYPO3\CMS\T3editor;
+namespace TYPO3\CMS\T3editor\Controller;
 
 /*
  * This file is part of the TYPO3 CMS project.
@@ -21,7 +21,7 @@ use TYPO3\CMS\Core\Http\JsonResponse;
 /**
  * Code completion for t3editor
  */
-class CodeCompletion
+class CodeCompletionController
 {
     /**
      * @var \TYPO3\CMS\Core\Http\AjaxRequestHandler
@@ -43,7 +43,7 @@ class CodeCompletion
      * @param ServerRequestInterface $request
      * @return ResponseInterface
      */
-    public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface
+    public function loadCompletions(ServerRequestInterface $request): ResponseInterface
     {
         $pageId = (int)($request->getParsedBody()['pageId'] ?? $request->getQueryParams()['pageId']);
         return $this->loadTemplates($pageId);
diff --git a/typo3/sysext/t3editor/Configuration/Backend/AjaxRoutes.php b/typo3/sysext/t3editor/Configuration/Backend/AjaxRoutes.php
index 8af7cb2ee916..7a0f00cbd67d 100644
--- a/typo3/sysext/t3editor/Configuration/Backend/AjaxRoutes.php
+++ b/typo3/sysext/t3editor/Configuration/Backend/AjaxRoutes.php
@@ -13,6 +13,6 @@ return [
     // Load code completion templates
     't3editor_codecompletion_loadtemplates' => [
         'path' => '/t3editor/codecompletion/load-templates',
-        'target' => \TYPO3\CMS\T3editor\CodeCompletion::class . '::processAjaxRequest'
+        'target' => \TYPO3\CMS\T3editor\Controller\CodeCompletionController::class . '::loadCompletions'
     ]
 ];
diff --git a/typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php b/typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php
new file mode 100644
index 000000000000..d8e5c23a48d7
--- /dev/null
+++ b/typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php
@@ -0,0 +1,4 @@
+<?php
+return [
+    'TYPO3\\CMS\\T3editor\\CodeCompletion' => \TYPO3\CMS\T3editor\Controller\CodeCompletionController::class,
+];
diff --git a/typo3/sysext/t3editor/Migrations/Code/LegacyClassesForIde.php b/typo3/sysext/t3editor/Migrations/Code/LegacyClassesForIde.php
new file mode 100644
index 000000000000..44cfd020bcfb
--- /dev/null
+++ b/typo3/sysext/t3editor/Migrations/Code/LegacyClassesForIde.php
@@ -0,0 +1,13 @@
+<?php
+namespace {
+    die('Access denied');
+}
+
+namespace TYPO3\CMS\T3editor {
+    /**
+     * @deprecated since v9, will be removed in v10
+     */
+    class CodeCompletion extends \TYPO3\CMS\T3editor\Controller\CodeCompletionController
+    {
+    }
+}
diff --git a/typo3/sysext/t3editor/composer.json b/typo3/sysext/t3editor/composer.json
index 7f2a88ba5efb..6610a3ed73f2 100644
--- a/typo3/sysext/t3editor/composer.json
+++ b/typo3/sysext/t3editor/composer.json
@@ -28,6 +28,11 @@
 				"partOfFactoryDefault": true
 			},
 			"extension-key": "t3editor"
+		},
+		"typo3/class-alias-loader": {
+			"class-alias-maps": [
+				"Migrations/Code/ClassAliasMap.php"
+			]
 		}
 	},
 	"autoload": {
-- 
GitLab