ModifyRecordsAfterFetchingContentEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\ModifyRecordsAfterFetchingContentEvent allows to modify the fetched records next to the possibility to manipulate most of the options, such as slide. Listeners are also able to set the final content and change the whole TypoScript configuration, used for further processing.

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\ModifyRecordsAfterFetchingContentEvent;

#[AsEventListener(
    identifier: 'my-extension/my-event-listener',
)]
final readonly class MyEventListener
{
    public function __invoke(ModifyRecordsAfterFetchingContentEvent $event): void
    {
        if ($event->getConfiguration()['table'] !== 'tt_content') {
            return;
        }

        $records = array_reverse($event->getRecords());
        $event->setRecords($records);
    }
}
Copied!

New in version 13.0

API

class ModifyRecordsAfterFetchingContentEvent
Fully qualified name
\TYPO3\CMS\Frontend\ContentObject\Event\ModifyRecordsAfterFetchingContentEvent

Event which is fired after ContentContentObject has pulled records from database.

Therefore, allows listeners to completely manipulate the fetched records, prior to being further processed by the content object.

Additionally, the event also allows to manipulate the configuration and options, such as the "value" or "slide".

getRecords ( )
Returns
array
setRecords ( array $records)
param $records

the records

getFinalContent ( )
Returns
string
setFinalContent ( string $finalContent)
param $finalContent

the finalContent

getSlide ( )
Returns
int
setSlide ( int $slide)
param $slide

the slide

getSlideCollect ( )
Returns
int
setSlideCollect ( int $slideCollect)
param $slideCollect

the slideCollect

getSlideCollectReverse ( )
Returns
bool
setSlideCollectReverse ( bool $slideCollectReverse)
param $slideCollectReverse

the slideCollectReverse

getSlideCollectFuzzy ( )
Returns
bool
setSlideCollectFuzzy ( bool $slideCollectFuzzy)
param $slideCollectFuzzy

the slideCollectFuzzy

getConfiguration ( )
Returns
array
setConfiguration ( array $configuration)
param $configuration

the configuration