BeforeRecordDownloadIsExecutedEvent

The event \TYPO3\CMS\Backend\RecordList\Event\BeforeRecordDownloadIsExecutedEvent can be used to modify the result of a download / export initiated via the Web > List module.

The event lets you change both the main part and the header of the data file. You can use it to edit data to follow GDPR rules, change or translate data, create backups or web hooks, record who accesses the data, and more.

Example: Redact columns with private content in exports

EXT:my_extension/Classes/Backend/EventListener/DataListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Backend\EventListener;

use TYPO3\CMS\Backend\RecordList\Event\BeforeRecordDownloadIsExecutedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

#[AsEventListener(identifier: 'my-package/record-list-download-data')]
final readonly class DataListener
{
    public function __invoke(BeforeRecordDownloadIsExecutedEvent $event): void
    {
        // List of redactable fields.
        $gdprFields = ['title', 'author'];

        $headerRow = $event->getHeaderRow();
        $records = $event->getRecords();

        // Iterate header to mark redacted fields...
        foreach ($headerRow as $headerRowKey => $headerRowValue) {
            if (in_array($headerRowKey, $gdprFields, true)) {
                $headerRow[$headerRowKey] .= ' (REDACTED)';
            }
        }

        // Redact actual content...
        foreach ($records as $index => $record) {
            foreach ($gdprFields as $gdprField) {
                if (isset($record[$gdprField])) {
                    $records[$index][$gdprField] = '(REDACTED)';
                }
            }
        }

        $event->setHeaderRow($headerRow);
        $event->setRecords($records);
    }
}
Copied!

API of BeforeRecordDownloadIsExecutedEvent

class BeforeRecordDownloadIsExecutedEvent
Fully qualified name
\TYPO3\CMS\Backend\RecordList\Event\BeforeRecordDownloadIsExecutedEvent

Listeners to this event are able to manipulate the download of records, usually triggered via Web > List.

getHeaderRow ( )
Returns
array
setHeaderRow ( array $headerRow)
param $headerRow

the headerRow

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

the records

getRequest ( )
Returns
\Psr\Http\Message\ServerRequestInterface
getTable ( )
Returns
string
getFormat ( )
Returns
string
getFilename ( )
Returns
string
getId ( )
Returns
int
getModTSconfig ( )
Returns
array
getColumnsToRender ( )
Returns
array
isHideTranslations ( )
Returns
bool