Feature: #110815 - PSR-14 event after a record is rendered 

See forge#110815

Description 

The new PSR-14 event \TYPO3\CMS\Frontend\ContentObject\Event\AfterRecordIsRenderedEvent is dispatched by the CONTENT and RECORDS content objects after each single record has been rendered. It allows modifying the rendered content of the record, for example to wrap it in additional markup.

It is the counterpart to \TYPO3\CMS\Fluid\Event\ModifyRenderedRecordEvent , which is dispatched for records rendered with the <f:render.record> and <f:render.contentArea> ViewHelpers.

The event provides the following methods:

getRenderedRecord()
Returns the rendered content of the record.
setRenderedRecord()
Replaces the rendered content of the record. Make sure to return escaped content if necessary.
getRecord()
Returns the rendered record as \TYPO3\CMS\Core\Domain\RecordInterface , like ModifyRenderedRecordEvent does. This is usually a resolved record. If the row cannot be resolved, for example because a custom select.selectFields omits system fields such as the language or workspace fields, a \TYPO3\CMS\Core\Domain\RawRecord holding the unprocessed row is provided instead.
getRequest()
Returns the current request.

The event is not dispatched for tables without TCA, or if a custom select.selectFields omits the type field of the table, since no record object can be created then. The rendered content of such records is returned unmodified.

Example 

EXT:my_extension/Classes/EventListener/WrapRenderedRecord.php
namespace MyVendor\MyExtension\EventListener;

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

final class WrapRenderedRecord
{
    #[AsEventListener]
    public function __invoke(AfterRecordIsRenderedEvent $event): void
    {
        if ($event->getRecord()->getMainType() !== 'tt_content') {
            return;
        }
        $event->setRenderedRecord(
            '<div class="my-record">' . $event->getRenderedRecord() . '</div>'
        );
    }
}
Copied!

Impact 

Listeners can modify the output of every record rendered by the CONTENT and RECORDS content objects, for example the content elements of a page rendered with styles.content.get .