Feature: #102849 - PSR-14 event for manipulating store cache functionality of stdWrap

See forge#102849

Description

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

The event is being dispatched just before the final stdWrap content is added to the cache and allows to fully manipulate the $content to be added, the cache $tags to be used as well as the corresponding cache $key and the cache $lifetime. Therefore, listeners can use the public getter and setter methods.

Additionally, the new event provides the full TypoScript $configuration and the current $contentObjectRenderer instance.

Example

The event listener class, using the PHP attribute #[AsEventListener] for registration:

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapContentStoredInCacheEvent;

final class BeforeStdWrapContentStoredInCacheEventListener
{
    #[AsEventListener]
    public function __invoke(BeforeStdWrapContentStoredInCacheEvent $event): void
    {
        if (in_array('foo', $event->getTags(), true)) {
            $event->setContent('modified-content');
        }
    }
}

Impact

Using the new PSR-14 event, it's now possible to fully manipulate the content, the cache tags as well as further relevant information, used by the caching functionality of stdWrap.