Feature: #102581 - PSR-14 event for modifying ContentObjectRenderer¶
See forge#102581
Description¶
A new PSR-14 event \TYPO3\
has been introduced which serves as a drop-in replacement for the now removed
hook $GLOBALS
.
The event is being dispatched after Content
has been
initialized in its start
method. The Content
instance can be accessed using the get
method.
Example¶
The event listener class, using the PHP attribute #
for
registration:
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\AfterContentObjectRendererInitializedEvent;
final class AfterContentObjectRendererInitializedEventListener
{
#[AsEventListener]
public function __invoke(AfterContentObjectRendererInitializedEvent $event): void
{
$event->getContentObjectRenderer()->setCurrentVal('My current value');
}
}
Impact¶
Using the new PSR-14 event, it's now possible to modify the
Content
instance, after it has been initialized.