BeforeRecordDownloadIsExecutedEvent
New in version 13.2
This PSR-14 event replaces the
$GLOBALS
and
$GLOBALS
,
hooks, which have been deprecated with TYPO3 v13.2.
The event \TYPO3\
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.
Table of contents
Example: Redact columns with private content in exports
<?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);
}
}