BeforeStdWrapContentStoredInCacheEvent

New in version 13.0: This event serves as a more powerful replacement for the removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap_cacheStore'].

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapContentStoredInCacheEvent is dispatched just before the final stdWrap content is added to the cache. It 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.

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

Example

EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Frontend\EventListener;

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

#[AsEventListener(
    identifier: 'my-extension/before-stdwrap-content-stored-in-cache'
)]
final class MyEventListener
{
    public function __invoke(BeforeStdWrapContentStoredInCacheEvent $event): void
    {
        if (in_array('foo', $event->getTags(), true)) {
            $event->setContent('modified-content');
        }
    }
}

New in version 13.0: The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, you can also register an event listener via the Configuration/Services.yaml file. Have a look into the section Implementing an event listener in your extension.

API

class TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapContentStoredInCacheEvent

Listeners to this Event are able to modify the final stdWrap content and corresponding cache tags, before being stored in cache.

Additionally, listeners are also able to change the cache key to be used as well as the lifetime. Therefore, the whole configuration is available.

getContent()
Return type

string

setContent(string $content)
Parameters
  • $content (string) -- the content

getTags()
Return type

array

setTags(array $tags)
Parameters
  • $tags (array) -- the tags

getKey()
Return type

string

setKey(string $key)
Parameters
  • $key (string) -- the key

getLifetime()
Return type

int

setLifetime(int $lifetime)
Parameters
  • $lifetime (int) -- the lifetime

getConfiguration()
Return type

array

getContentObjectRenderer()
Return type

TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer