From 8a119296628b77a289f1c0e062b61cd07862fee6 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Sat, 17 Mar 2018 10:05:40 +0100 Subject: [PATCH] [TASK] Move class RecordList to Controller/RecordListController Class TYPO3\CMS\Recordlist\RecordList is the list module main controller and thus should be rename to TYPO3\CMS\Recordlist\Controller\RecordListController Resolves: #84399 Releases: master Change-Id: I77ca1c2f9841e234bde2dd571d8875db5c0e0b14 Reviewed-on: https://review.typo3.org/56275 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de> Tested-by: Mathias Brodala <mbrodala@pagemachine.de> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> 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 +- .../Controller/PageLayoutController.php | 5 +-- .../backend/Classes/View/PageLayoutView.php | 1 - ...ecordListRenamedToRecordListController.rst | 38 +++++++++++++++++++ .../ExtensionScanner/Php/ClassNameMatcher.php | 5 +++ .../RecordListController.php} | 15 ++++---- .../Migrations/Code/ClassAliasMap.php | 4 ++ .../Migrations/Code/LegacyClassesForIde.php | 13 +++++++ typo3/sysext/recordlist/composer.json | 5 +++ typo3/sysext/recordlist/ext_tables.php | 2 +- .../sys_note/Classes/Hook/RecordListHook.php | 9 +++-- 12 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-84399-ClassRecordListRenamedToRecordListController.rst rename typo3/sysext/recordlist/Classes/{RecordList.php => Controller/RecordListController.php} (98%) create mode 100644 typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php create mode 100644 typo3/sysext/recordlist/Migrations/Code/LegacyClassesForIde.php diff --git a/composer.json b/composer.json index c0deb34aae4b..a0c100488233 100644 --- a/composer.json +++ b/composer.json @@ -86,6 +86,7 @@ "typo3/sysext/fluid/Migrations/Code/ClassAliasMap.php", "typo3/sysext/info/Migrations/Code/ClassAliasMap.php", "typo3/sysext/lowlevel/Migrations/Code/ClassAliasMap.php", + "typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php", "typo3/sysext/reports/Migrations/Code/ClassAliasMap.php", "typo3/sysext/saltedpasswords/Migrations/Code/ClassAliasMap.php", "typo3/sysext/workspaces/Migrations/Code/ClassAliasMap.php" diff --git a/composer.lock b/composer.lock index edc4866b0138..898274f867e4 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": "c2fe666b163be8ccee13df7d63c794cc", + "content-hash": "33161a8bc06421b8de725e3dfb422fae", "packages": [ { "name": "cogpowered/finediff", diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index b11a6d46868c..5cc7768843bf 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -39,7 +39,6 @@ use TYPO3\CMS\Core\Versioning\VersionState; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; use TYPO3\CMS\Frontend\Page\PageRepository; -use TYPO3\CMS\Recordlist\RecordList; /** * Script Class for Web > Layout module @@ -260,7 +259,7 @@ class PageLayoutController $this->MCONF['name'] = $this->moduleName; $this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW); // Get session data - $sessionData = $this->getBackendUser()->getSessionData(RecordList::class); + $sessionData = $this->getBackendUser()->getSessionData(__CLASS__); $this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : ''; // GPvars: $this->id = (int)GeneralUtility::_GP('id'); @@ -274,7 +273,7 @@ class PageLayoutController $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl')); $sessionData['search_field'] = $this->search_field; // Store session data - $this->getBackendUser()->setAndSaveSessionData(RecordList::class, $sessionData); + $this->getBackendUser()->setAndSaveSessionData(__CLASS__, $sessionData); // Load page info array: $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); // Initialize menu diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index b39330499cac..8a806b78c5e8 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -2680,7 +2680,6 @@ class PageLayoutView implements LoggerAwareInterface * Initializes the clipboard for generating paste links * * - * @see \TYPO3\CMS\Recordlist\RecordList::main() * @see \TYPO3\CMS\Backend\Controller\ContextMenuController::clipboardAction() * @see \TYPO3\CMS\Filelist\Controller\FileListController::indexAction() */ diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84399-ClassRecordListRenamedToRecordListController.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84399-ClassRecordListRenamedToRecordListController.rst new file mode 100644 index 000000000000..cf965eb94774 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-84399-ClassRecordListRenamedToRecordListController.rst @@ -0,0 +1,38 @@ +.. include:: ../../Includes.txt + +====================================================================== +Deprecation: #84399 - Class RecordList renamed to RecordListController +====================================================================== + +See :issue:`84399` + +Description +=========== + +The PHP class :php:`TYPO3\CMS\Recordlist\RecordList` has been renamed to +:php:`TYPO3\CMS\Recordlist\Controller\RecordListController` + + +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 that hook into the list module may be affected if type hinting +with the old classes as :php:`$parentObject`. + +The extension scanner will find affected extensions using the old class name. + + +Migration +========= + +Use new class name instead. + +.. index:: Backend, PHP-API, FullyScanned, ext:recordlist \ 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 173eb5651629..5ac17f7bfcd2 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php @@ -654,4 +654,9 @@ return [ 'Deprecation-84109-DeprecateDependencyResolver.rst', ], ], + 'TYPO3\CMS\Recordlist\RecordList' => [ + 'restFiles' => [ + 'Deprecation-84399-ClassRecordListRenamedToRecordListController.rst', + ], + ], ]; diff --git a/typo3/sysext/recordlist/Classes/RecordList.php b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php similarity index 98% rename from typo3/sysext/recordlist/Classes/RecordList.php rename to typo3/sysext/recordlist/Classes/Controller/RecordListController.php index 84c7495ce8c8..2d42972b25ab 100644 --- a/typo3/sysext/recordlist/Classes/RecordList.php +++ b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php @@ -1,5 +1,5 @@ <?php -namespace TYPO3\CMS\Recordlist; +namespace TYPO3\CMS\Recordlist\Controller; /* * This file is part of the TYPO3 CMS project. @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Recordlist; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Clipboard\Clipboard; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Backend\Template\ModuleTemplate; @@ -36,11 +37,12 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Versioning\VersionState; +use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; /** * Script Class for the Web > List module; rendering the listing of records on a page */ -class RecordList +class RecordListController { /** * Page Id for which to make the listing @@ -310,10 +312,8 @@ class RecordList } // Initialize the dblist object: - /** @var $dblist RecordList\DatabaseRecordList */ - $dblist = GeneralUtility::makeInstance(RecordList\DatabaseRecordList::class); - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $dblist = GeneralUtility::makeInstance(DatabaseRecordList::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $dblist->script = (string)$uriBuilder->buildUriFromRoute('web_list'); $dblist->calcPerms = $calcPerms; $dblist->thumbs = $backendUser->uc['thumbnailsByDefault']; @@ -722,8 +722,7 @@ class RecordList 'justLocalized' => 'pages:' . $id . ':' . $languageUid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') ]; - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters); $targetUrl = BackendUtility::getLinkToDataHandlerAction( '&cmd[pages][' . $id . '][localize]=' . $languageUid, diff --git a/typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php b/typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php new file mode 100644 index 000000000000..9b2c8ed6c9fe --- /dev/null +++ b/typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php @@ -0,0 +1,4 @@ +<?php +return [ + 'TYPO3\\CMS\\Recordlist\\RecordList' => \TYPO3\CMS\Recordlist\Controller\RecordListController::class, +]; diff --git a/typo3/sysext/recordlist/Migrations/Code/LegacyClassesForIde.php b/typo3/sysext/recordlist/Migrations/Code/LegacyClassesForIde.php new file mode 100644 index 000000000000..349b05498e56 --- /dev/null +++ b/typo3/sysext/recordlist/Migrations/Code/LegacyClassesForIde.php @@ -0,0 +1,13 @@ +<?php +namespace { + die('Access denied'); +} + +namespace TYPO3\CMS\Recordlist { + /** + * @deprecated since v9, will be removed in v10 + */ + class RecordList extends \TYPO3\CMS\Recordlist\Controller\RecordListController + { + } +} diff --git a/typo3/sysext/recordlist/composer.json b/typo3/sysext/recordlist/composer.json index 3cfc5dd2c3dc..479c0c3e186a 100644 --- a/typo3/sysext/recordlist/composer.json +++ b/typo3/sysext/recordlist/composer.json @@ -30,6 +30,11 @@ "partOfMinimalUsableSystem": true }, "extension-key": "recordlist" + }, + "typo3/class-alias-loader": { + "class-alias-maps": [ + "Migrations/Code/ClassAliasMap.php" + ] } }, "autoload": { diff --git a/typo3/sysext/recordlist/ext_tables.php b/typo3/sysext/recordlist/ext_tables.php index 88ce599aebf2..d5989fe239cb 100644 --- a/typo3/sysext/recordlist/ext_tables.php +++ b/typo3/sysext/recordlist/ext_tables.php @@ -7,7 +7,7 @@ defined('TYPO3_MODE') or die(); '', '', [ - 'routeTarget' => \TYPO3\CMS\Recordlist\RecordList::class . '::mainAction', + 'routeTarget' => \TYPO3\CMS\Recordlist\Controller\RecordListController::class . '::mainAction', 'access' => 'user,group', 'name' => 'web_list', 'icon' => 'EXT:recordlist/Resources/Public/Icons/module-list.svg', diff --git a/typo3/sysext/sys_note/Classes/Hook/RecordListHook.php b/typo3/sysext/sys_note/Classes/Hook/RecordListHook.php index c5241a522d64..6f5b3a6ace2b 100644 --- a/typo3/sysext/sys_note/Classes/Hook/RecordListHook.php +++ b/typo3/sysext/sys_note/Classes/Hook/RecordListHook.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\SysNote\Hook; */ use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Recordlist\Controller\RecordListController; use TYPO3\CMS\SysNote\Controller\NoteController; use TYPO3\CMS\SysNote\Domain\Repository\SysNoteRepository; @@ -28,10 +29,10 @@ class RecordListHook * Add sys_notes as additional content to the header of the list module * * @param array $params - * @param \TYPO3\CMS\Recordlist\RecordList $parentObject + * @param RecordListController $parentObject * @return string */ - public function renderInHeader(array $params = [], \TYPO3\CMS\Recordlist\RecordList $parentObject) + public function renderInHeader(array $params = [], RecordListController $parentObject) { $controller = GeneralUtility::makeInstance(NoteController::class); return $controller->listAction($parentObject->id, SysNoteRepository::SYS_NOTE_POSITION_TOP); @@ -41,10 +42,10 @@ class RecordListHook * Add sys_notes as additional content to the footer of the list module * * @param array $params - * @param \TYPO3\CMS\Recordlist\RecordList $parentObject + * @param RecordListController $parentObject * @return string */ - public function renderInFooter(array $params = [], \TYPO3\CMS\Recordlist\RecordList $parentObject) + public function renderInFooter(array $params = [], RecordListController $parentObject) { $controller = GeneralUtility::makeInstance(NoteController::class); return $controller->listAction($parentObject->id, SysNoteRepository::SYS_NOTE_POSITION_BOTTOM); -- GitLab