ModifyBlindedConfigurationOptionsEvent¶
New in version 12.2: The event serves as a direct replacement for the deprecated hook
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Lowlevel\Controller\ConfigurationController']['modifyBlindedConfigurationOptions']
.
The PSR-14 event \TYPO3\CMS\Lowlevel\Event\ModifyBlindedConfigurationOptionsEvent
is fired in the \TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider
and the \TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\SitesYamlConfigurationProvider
while building the configuration array to be displayed in the
System > Configuration module. It allows to blind (hide) any
configuration options. Usually such options are passwords or other sensitive
information.
Using the getProviderIdentifier()
method of the event, 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 configuration module.
Example¶
Registration of the ModifyBlindedConfigurationOptionsEvent
in your
extension's Services.yaml
:
MyVendor\MyExtension\Backend\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/blind-configuration-options'
The corresponding event listener:
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
{
$options = $event->getBlindedConfigurationOptions();
if ($event->getProviderIdentifier() === 'sitesYamlConfiguration') {
$options['my-site']['settings']['apiKey'] = '***';
} elseif ($event->getProviderIdentifier() === 'confVars') {
$options['TYPO3_CONF_VARS']['EXTENSIONS']['my_extension']['password'] = '***';
}
$event->setBlindedConfigurationOptions($options);
}
}
API¶
- class TYPO3\CMS\Lowlevel\Event\ModifyBlindedConfigurationOptionsEvent¶
Listeners to this Event will be able to modify the blinded configuration options, displayed in the configuration module of the TYPO3 backend.
- setBlindedConfigurationOptions(array $blindedConfigurationOptions)¶
Allows to define configuration options to be blinded
- Parameters
$blindedConfigurationOptions (
array
) -- the blindedConfigurationOptions
- getBlindedConfigurationOptions()¶
Returns the blinded configuration options
- Return type
array
- getProviderIdentifier()¶
Returns the configuration provider identifier, dispatching the event
- Return type
string