Feature: #102581 - PSR-14 event for modifying ContentObjectRenderer

See forge#102581

Description

A new PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\AfterContentObjectRendererInitializedEvent has been introduced which serves as a drop-in replacement for the now removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'].

The event is being dispatched after ContentObjectRenderer has been initialized in its start() method. The ContentObjectRenderer instance can be accessed using the getContentObjectRenderer() method.

Example

The event listener class, using the PHP attribute #[AsEventListener] 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 ContentObjectRenderer instance, after it has been initialized.