Feature: #98016 - PSR-14 EvaluateModifierFunctionEvent
See forge#98016
Description
A new PSR-14 event \TYPO3\
has been introduced which allows own TypoScript functions using the :=
operator.
This is a substitution of the old
$GLOBALS
hook as described in this Changelog.
Impact
The TYPO3 Core tests come with test extension
EXT:
to functional
test the new event. The extension implements an example listener that can be used as boilerplate.
A simple TypoScript example looks like this:
someIdentifier = originalValue
someIdentifier := myModifierFunction(myFunctionArgument)
To implement my
, an extension needs to register an event listener
in file Configuration/
:
MyVendor\MyPackage\EventListener\MyTypoScriptModifierFunction:
tags:
- name: event.listener
identifier: 'my-package/typoscript/evaluate-modifier-function'
The corresponding event listener class could look like this:
use TYPO3\CMS\Core\TypoScript\AST\Event\EvaluateModifierFunctionEvent;
final class MyTypoScriptModifierFunction
{
public function __invoke(EvaluateModifierFunctionEvent $event): void
{
if ($event->getFunctionName() === 'myModifierFunction') {
$originalValue = $event->getOriginalValue();
$functionArgument = $event->getFunctionArgument();
// Manipulate values and set new value
$event->setValue($originalValue . ' example ' . $functionArgument);
}
}
}