Skip to content

Commit

Permalink
[REFACTOR] Changes backend module registration for m1, m3, m5
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhoffmann1979 committed Nov 6, 2023
1 parent fa91714 commit d568010
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 52 deletions.
89 changes: 89 additions & 0 deletions Configuration/Backend/Modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

declare(strict_types=1);

/*
* Copyright notice
*
* (c) 2023 in2code.de and the following authors:
* Daniel Hoffmann <[email protected]>
*
* 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;
45 changes: 45 additions & 0 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/*
* Copyright notice
*
* (c) 2023 in2code.de and the following authors:
* Daniel Hoffmann <[email protected]>
*
* 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',
],
];
115 changes: 63 additions & 52 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 *****************************************************/
Expand All @@ -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')) {
Expand All @@ -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;
Expand Down Expand Up @@ -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',
],
);
}

})();

0 comments on commit d568010

Please sign in to comment.