Feature: #99717 - New PSR-14 ModifyBlindedConfigurationOptionsEvent
See forge#99717
Description
A new PSR-14 event \TYPO3\
has been introduced which serves as a direct replacement for the
now deprecated hook
$GLOBALS
.
The new PSR-14 event is fired in the
\TYPO3\
and the
\TYPO3\
,
while building the corresponding configuration array, which should be displayed
in the Configuration module. The event therefore allows to
blind (hide) any of those configuration options. Usually, such options are
passwords or any other sensitive information.
Using the Modify
method, listeners are able to determine the context, the event got dispatched
in. This is useful to prevent duplicate code execution, since the event is
dispatched for multiple providers. The method returns the identifier of
the configuration provider as registered in the
service configuration.
Example
Registration of the Modify
in your
extension's Services.
:
MyVendor\MyExtension\Backend\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/blind-configuration-options'
The corresponding event listener class:
namespace MyVendor\MyExtension\Backend;
use TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider;
use TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\SitesYamlConfigurationProvider;
use TYPO3\CMS\Lowlevel\Event\ModifyBlindedConfigurationOptionsEvent;
final class MyEventListener {
public function __invoke(ModifyBlindedConfigurationOptionsEvent $event): void
{
$blindedConfigurationOptions = $event->getBlindedConfigurationOptions();
if ($event->getProviderIdentifier() === 'sitesYamlConfiguration') {
$blindedConfigurationOptions['my-site']['settings']['apiKey'] = '***';
} elseif ($event->getProviderIdentifier() === 'confVars') {
$blindedConfigurationOptions['TYPO3_CONF_VARS']['EXTENSIONS']['my_extension']['password'] = '******';
}
$event->setBlindedConfigurationOptions($blindedConfigurationOptions);
}
}
Impact
With the new Modify
, it is
now possible to modify global configuration options as well as site
configuration options, displayed in the Configuration module.
The event might be triggered by more configuration providers in the future.