BeforeRecordDownloadPresetsAreDisplayedEvent¶
New in version 13.2
The event \TYPO3\
can be used to manipulate the list of available download presets in
the Web > List module.
See mod.web_list.downloadPresets on how to configure download presets.
Note that the event is dispatched for one specific database table name. If an event listener is created to attach presets to different tables, the listener method must check for the table name, as shown in the example below.
If no download presets exist for a given table, the PSR-14 event can still
be used to modify and add presets to it via the set
method.
The array passed from get
to set
can contain
an array collection of TYPO3CMSBackendRecordListDownloadPreset
objects with the array key using the preset label.
The event listener can also remove array indexes, or also columns of existing
array entries by passing a newly constructed Download
object with the
changed label
and columns
constructor properties.
Table of contents
Example: Manipulate download presets¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\RecordList\EventListener;
use TYPO3\CMS\Backend\RecordList\DownloadPreset;
use TYPO3\CMS\Backend\RecordList\Event\BeforeRecordDownloadPresetsAreDisplayedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(identifier: 'my-extension/modify-record-list-preset')]
final readonly class PresetListener
{
public function __invoke(BeforeRecordDownloadPresetsAreDisplayedEvent $event): void
{
$presets = $event->getPresets();
$newPresets = match ($event->getDatabaseTable()) {
'be_users' => [new DownloadPreset('PSR-14 preset', ['uid', 'email'])],
'pages' => [
new DownloadPreset('PSR-14 preset', ['title']),
new DownloadPreset('Another PSR-14 preset', ['title', 'doktype']),
],
'tx_myvendor_myextension' => [new DownloadPreset('PSR-14 preset', ['uid', 'something'])],
};
foreach ($newPresets as $newPreset) {
$presets[] = $newPreset;
}
$presets[] = new DownloadPreset('Available everywhere, simple UID list', ['uid']);
$presets['some-identifier'] = new DownloadPreset('Overwrite preset', ['uid', 'pid'], 'some-identifier');
$event->setPresets($presets);
}
}
API of BeforeRecordDownloadPresetsAreDisplayedEvent¶
- class BeforeRecordDownloadPresetsAreDisplayedEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Record List\ Event\ Before Record Download Presets Are Displayed Event
Event to manipulate the available list of download presets.
Array $presets contains a list of DownloadPreset objects with their methods:
get
,Identifier () get
andLabel () get
.Columns () The event is always coupled to a specific database table.
- getPresets ( ) ¶
-
- Returns
-
\Download
Preset []
- setPresets ( array $presets) ¶
-
- param $presets
-
the presets
- getDatabaseTable ( ) ¶
-
- Returns
-
string
- getRequest ( ) ¶
-
- Returns
-
\Psr\
Http\ Message\ Server Request Interface
- getId ( ) ¶
-
- Returns
-
int