From 64204e041d5b05c68cd5749b8063ca06abfc2d36 Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Mon, 29 Nov 2021 23:34:51 +0100 Subject: [PATCH] [FEATURE] Show registered toolbar items in configuration module With #96041 the registration of toolbar items was changed. All implementations of the corresponding interface are now automatically registered. The $GLOBALS configuration does no longer have any effect. An administrator however was no longer able to get an overview of the registered toolbar items in the configuration module. Therefore, this patch improves the situation by adding a new configuration provider, which in contrast to the GlobalVariableProvider, already shows the final ordering. Resolves: #96152 Related: #96041 Releases: main Change-Id: Ieba1988e65fa777aa0c71c258c0bac9e76a10ecb Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72392 Tested-by: Jochen <rothjochen@gmail.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Jochen <rothjochen@gmail.com> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de> --- ...lbarItemsOverviewInConfigurationModule.rst | 27 ++++++++++++ .../ToolbarItemsProvider.php | 42 +++++++++++++++++++ .../lowlevel/Configuration/Services.yaml | 9 ++++ .../Resources/Private/Language/locallang.xlf | 3 ++ 4 files changed, 81 insertions(+) create mode 100644 typo3/sysext/core/Documentation/Changelog/12.0/Feature-96152-BackendToolbarItemsOverviewInConfigurationModule.rst create mode 100644 typo3/sysext/lowlevel/Classes/ConfigurationModuleProvider/ToolbarItemsProvider.php diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Feature-96152-BackendToolbarItemsOverviewInConfigurationModule.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-96152-BackendToolbarItemsOverviewInConfigurationModule.rst new file mode 100644 index 000000000000..5dfabc214aee --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Feature-96152-BackendToolbarItemsOverviewInConfigurationModule.rst @@ -0,0 +1,27 @@ +.. include:: ../../Includes.txt + +======================================================================== +Feature: #96152 - Backend Toolbar items overview in configuration module +======================================================================== + +See :issue:`96152` + +Description +=========== + +With :issue:`96041`, the registration of backend toolbar items had been +improved. Instead of being registered via :php:`$GLOBALS`, all implementations +of :php:`ToolbarItemsInterface` are now automatically registered, while taking +the defined :php:`index` into account. + +To still allow administrators an overview of the registered toolbar items, +especially the final ordering, a corresponding list has been added to +the configuration module. + +Impact +====== + +It's now possible for administrators to get an overview of all registered +toolbar items and the final ordering in the configuration module. + +.. index:: Backend, ext:lowlevel diff --git a/typo3/sysext/lowlevel/Classes/ConfigurationModuleProvider/ToolbarItemsProvider.php b/typo3/sysext/lowlevel/Classes/ConfigurationModuleProvider/ToolbarItemsProvider.php new file mode 100644 index 000000000000..1a697151f249 --- /dev/null +++ b/typo3/sysext/lowlevel/Classes/ConfigurationModuleProvider/ToolbarItemsProvider.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); + +/* + * 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! + */ + +namespace TYPO3\CMS\Lowlevel\ConfigurationModuleProvider; + +use TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry; + +class ToolbarItemsProvider extends AbstractProvider +{ + protected ToolbarItemsRegistry $toolbarItemsRegistry; + + public function __construct(ToolbarItemsRegistry $toolbarItemsRegistry) + { + $this->toolbarItemsRegistry = $toolbarItemsRegistry; + } + + public function getConfiguration(): array + { + $configuration = []; + foreach ($this->toolbarItemsRegistry->getToolbarItems() as $item) { + $configuration[get_class($item)] = [ + 'index' => $item->getIndex(), + 'hasDropdown' => $item->hasDropDown(), + ]; + } + return $configuration; + } +} diff --git a/typo3/sysext/lowlevel/Configuration/Services.yaml b/typo3/sysext/lowlevel/Configuration/Services.yaml index 70a16b84c6d0..bf764ba5937d 100644 --- a/typo3/sysext/lowlevel/Configuration/Services.yaml +++ b/typo3/sysext/lowlevel/Configuration/Services.yaml @@ -216,4 +216,13 @@ services: - name: 'lowlevel.configuration.module.provider' identifier: 'softReferenceParsers' label: 'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:softReferenceParsers' + before: 'toolbaritems' after: 'mfaproviders' + + lowlevel.configuration.module.provider.toolbaritems: + class: 'TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\ToolbarItemsProvider' + tags: + - name: 'lowlevel.configuration.module.provider' + identifier: 'toolbaritems' + label: 'LLL:EXT:lowlevel/Resources/Private/Language/locallang.xlf:toolbarItems' + after: 'softReferenceParsers' diff --git a/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf b/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf index df2cc28d4bdf..6910c50d3c77 100644 --- a/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf +++ b/typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf @@ -45,6 +45,9 @@ <trans-unit id="softReferenceParsers" resname="softReferenceParsers"> <source>Soft Reference Parsers</source> </trans-unit> + <trans-unit id="toolbarItems" resname="toolbarItems"> + <source>Backend Toolbar Items</source> + </trans-unit> <trans-unit id="formYamlConfiguration" resname="formYamlConfiguration"> <source>Form: YAML Configuration</source> </trans-unit> -- GitLab