Attention
TYPO3 v10 has reached end-of-life as of April 30th 2023 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.
AddJavaScriptModulesEvent¶
JavaScript events in custom User Settings Configuration options should no longer be placed as inline JavaScript. Instead, use a dedicated JavaScript module to handle custom events.
Example¶
A listener using mentioned PSR-14 event could look like the following.
Register listener
typo3conf/my-extension/Configuration/Services.yaml
services: MyVendor\MyExtension\EventListener\CustomUserSettingsListener: tags: - name: event.listener identifier: 'myExtension/CustomUserSettingsListener' event: TYPO3\CMS\SetupEvent\AddJavaScriptModulesEvent
Implement Listener to load JavaScript module
TYPO3/CMS/MyExtension/CustomUserSettingsModule
namespace MyVendor\MyExtension\EventListener; use TYPO3\CMS\Setup\Event\AddJavaScriptModulesEvent; class CustomUserSettingsListener { // name of JavaScript module to be loaded private const MODULE_NAME = 'TYPO3/CMS/MyExtension/CustomUserSettingsModule'; public function __invoke(AddJavaScriptModulesEvent $event): void { $javaScriptModuleName = 'TYPO3/CMS/MyExtension/CustomUserSettings'; if (in_array(self::MODULE_NAME, $event->getModules(), true)) { return; } $event->addModule(self::MODULE_NAME); } }