From d568010e198dbbfff48002601bfb571393b80d84 Mon Sep 17 00:00:00 2001 From: Daniel Hoffmann Date: Mon, 6 Nov 2023 13:00:41 +0100 Subject: [PATCH] [REFACTOR] Changes backend module registration for m1, m3, m5 The backend modules overview, file & redirects are now registered via Configuration/Backend/Modules.php For TYPO3 v11 they are registered via the old way (ext_tables.php) The Icons are provided via Icons.php and can be retrieved from the IconFactory now. Resolves: https://projekte.in2code.de/issues/60077 --- Configuration/Backend/Modules.php | 89 +++++++++++++++++++++++ Configuration/Icons.php | 45 ++++++++++++ ext_tables.php | 115 ++++++++++++++++-------------- 3 files changed, 197 insertions(+), 52 deletions(-) create mode 100644 Configuration/Backend/Modules.php create mode 100644 Configuration/Icons.php diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php new file mode 100644 index 000000000..0ae965dbe --- /dev/null +++ b/Configuration/Backend/Modules.php @@ -0,0 +1,89 @@ + + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +use In2code\In2publishCore\Component\ConfigContainer\ConfigContainer; +use In2code\In2publishCore\Controller\FileController; +use In2code\In2publishCore\Controller\RecordController; +use In2code\In2publishCore\Features\RedirectsSupport\Controller\RedirectController; +use TYPO3\CMS\Core\Utility\GeneralUtility; + +$backendModulesToRegister = []; + +/** @var ConfigContainer $configContainer */ +$configContainer = GeneralUtility::makeInstance(ConfigContainer::class); + +if ($configContainer->get('module.m1')) { + $backendModulesToRegister['in2publish_core_m1'] = [ + 'parent' => 'web', + 'position' => [], + 'access' => 'user,group', + 'workspaces' => 'live', + 'path' => '/module/in2publish_core/m1', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod1.xlf', + 'extensionName' => 'in2publish_core', + 'iconIdentifier' => 'in2publish-core-overview-module', + 'controllerActions' => [ + RecordController::class => ['index', 'detail', 'publishRecord', 'toggleFilterStatus'], + ], + ]; +} + +if ($configContainer->get('module.m3')) { + $backendModulesToRegister['in2publish_core_m3'] = [ + 'parent' => 'file', + 'position' => [], + 'access' => 'user,group', + 'workspaces' => 'live', + 'path' => '/module/in2publish_core/m3', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod3.xlf', + 'extensionName' => 'in2publish_core', + 'iconIdentifier' => 'in2publish-core-file-module', + 'controllerActions' => [ + FileController::class => ['index', 'publishFolder', 'publishFile', 'toggleFilterStatus'], + ], + ]; +} + +if ($configContainer->get('features.redirectsSupport.enable')) { + $backendModulesToRegister['in2publish_core_m5'] = [ + 'parent' => 'site', + 'position' => ['after' => 'redirects/'], + 'access' => 'user,group', + 'workspaces' => 'live', + 'path' => '/module/in2publish_core/m5', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod5.xlf', + 'extensionName' => 'in2publish_core', + 'iconIdentifier' => 'in2publish-core-redirect-module', + 'controllerActions' => [ + RedirectController::class => ['list','publish','selectSite'], + ], + ]; +} + +return $backendModulesToRegister; diff --git a/Configuration/Icons.php b/Configuration/Icons.php new file mode 100644 index 000000000..34eb24fe5 --- /dev/null +++ b/Configuration/Icons.php @@ -0,0 +1,45 @@ + + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; + +return [ + 'in2publish-core-overview-module' => [ + 'provider' => SvgIconProvider::class, + 'source' => 'EXT:in2publish_core/Resources/Public/Icons/Overview.svg', + ], + 'in2publish-core-file-module' => [ + 'provider' => SvgIconProvider::class, + 'source' => 'EXT:in2publish_core/Resources/Public/Icons/File.svg', + ], + 'in2publish-core-redirect-module' => [ + 'provider' => SvgIconProvider::class, + 'source' => 'EXT:in2publish_core/Resources/Public/Icons/Redirect.svg', + ], +]; diff --git a/ext_tables.php b/ext_tables.php index c8c8bb599..571efacb9 100755 --- a/ext_tables.php +++ b/ext_tables.php @@ -33,6 +33,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; +use TYPO3\CMS\Core\Information\Typo3Version; (static function (): void { /***************************************************** Guards *****************************************************/ @@ -49,6 +50,8 @@ $contextService = GeneralUtility::makeInstance(ContextService::class); $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); $isForeign = $contextService->isForeign(); + /** @var Typo3Version $versionInformation */ + $versionInformation = GeneralUtility::makeInstance(Typo3Version::class); /******************************************* Colorize the BE on Foreign *******************************************/ if ($isForeign && $configContainer->get('features.warningOnForeign.colorizeHeader.enable')) { @@ -60,40 +63,67 @@ return; } - /******************************************** Register Backend Modules ********************************************/ - if ($configContainer->get('module.m1')) { - ExtensionUtility::registerModule( - 'in2publish_core', - 'web', - 'm1', - '', - [ - RecordController::class => 'index,detail,publishRecord,toggleFilterStatus', - ], - [ - 'access' => 'user,group', - 'icon' => 'EXT:in2publish_core/Resources/Public/Icons/Overview.svg', - 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod1.xlf', - ], - ); - } - if ($configContainer->get('module.m3')) { - ExtensionUtility::registerModule( - 'in2publish_core', - 'file', - 'm3', - '', - [ - FileController::class => 'index,publishFolder,publishFile,toggleFilterStatus', - ], - [ - 'access' => 'user,group', - 'icon' => 'EXT:in2publish_core/Resources/Public/Icons/File.svg', - 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod3.xlf', - ], - ); + if ($versionInformation->getMajorVersion() < 12) { + /** + * Deprecated registering of Backend Modules + * Register Backend Modules for TYPO3 v11 + * can be removed in TYPO3 v13 + */ + if ($configContainer->get('module.m1')) { + ExtensionUtility::registerModule( + 'in2publish_core', + 'web', + 'm1', + '', + [ + RecordController::class => 'index,detail,publishRecord,toggleFilterStatus', + ], + [ + 'access' => 'user,group', + 'iconIdentifier' => 'in2publish-core-overview-module', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod1.xlf', + ], + ); + } + if ($configContainer->get('module.m3')) { + ExtensionUtility::registerModule( + 'in2publish_core', + 'file', + 'm3', + '', + [ + FileController::class => 'index,publishFolder,publishFile,toggleFilterStatus', + ], + [ + 'access' => 'user,group', + 'iconIdentifier' => 'in2publish-core-file-module', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod3.xlf', + ], + ); + } + /************************************************ Redirect Support ************************************************/ + if ( + $configContainer->get('features.redirectsSupport.enable') + && ExtensionManagementUtility::isLoaded('redirects') + ) { + ExtensionUtility::registerModule( + 'in2publish_core', + 'site', + 'm5', + 'after:redirects', + [ + RedirectController::class => 'list,publish,selectSite', + ], + [ + 'access' => 'user,group', + 'iconIdentiefier' => 'in2publish-core-redirect-module', + 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod5.xlf', + ], + ); + } } + /******************************************* Context Menu Publish Entry *******************************************/ if ($configContainer->get('features.contextMenuPublishEntry.enable')) { $GLOBALS['TYPO3_CONF_VARS']['BE']['ContextMenu']['ItemProviders'][1595598780] = PublishItemProvider::class; @@ -127,24 +157,5 @@ $GLOBALS['in2publish_core']['tests'][] = SiteConfigurationTest::class; $GLOBALS['in2publish_core']['tests'][] = TableGarbageCollectorTest::class; - /************************************************ Redirect Support ************************************************/ - if ( - $configContainer->get('features.redirectsSupport.enable') - && ExtensionManagementUtility::isLoaded('redirects') - ) { - ExtensionUtility::registerModule( - 'in2publish_core', - 'site', - 'm5', - 'after:redirects', - [ - RedirectController::class => 'list,publish,selectSite', - ], - [ - 'access' => 'user,group', - 'icon' => 'EXT:in2publish_core/Resources/Public/Icons/Redirect.svg', - 'labels' => 'LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod5.xlf', - ], - ); - } + })();