EnhanceStdWrapEvent

New in version 13.0

This event is one of the more powerful replacements for the removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'].

Listeners to the PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\EnhanceStdWrapEvent are able to modify the stdWrap processing, enhancing the functionality and manipulating the final result/content. This is the parent event, which allows the corresponding listeners to be called on each step.

Child events:

All events provide the same functionality. The difference is only the execution order in which they are called in the stdWrap processing chain.

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\AfterStdWrapFunctionsExecutedEvent;
use TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsInitializedEvent;
use TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsInitializedEvent;
use TYPO3\CMS\Frontend\ContentObject\Event\EnhanceStdWrapEvent;

final readonly class MyEventListener
{
    #[AsEventListener(
        identifier: 'my-extension/my-stdwrap-enhancement',
    )]
    public function __invoke(EnhanceStdWrapEvent $event): void
    {
        // listen to all events
    }

    #[AsEventListener(
        identifier: 'my-extension/my-stdwrap-before-initialized',
    )]
    public function individualListener(BeforeStdWrapFunctionsInitializedEvent $event): void
    {
        // listen on BeforeStdWrapFunctionsInitializedEvent only
    }

    #[AsEventListener(
        identifier: 'my-extension/my-stdwrap-after-initialized-executed',
    )]
    public function listenOnMultipleEvents(
        AfterStdWrapFunctionsInitializedEvent|AfterStdWrapFunctionsExecutedEvent $event,
    ): void {
        // Union type to listen to different events
    }
}
Copied!

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

abstract class \TYPO3\CMS\Frontend\ContentObject\Event\ EnhanceStdWrapEvent

Listeners to this Event are able to modify the stdWrap processing, enhancing the functionality and manipulating the final result / content. This is the parent Event, which allows the corresponding listeners to be called on each step, see child Events:

getContent ( )
returntype

string

setContent ( string $content)
param string $content

the content

getConfiguration ( )
returntype

array

getContentObjectRenderer ( )
returntype

TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer