ModifyDatabaseQueryForRecordListingEvent

The PSR-14 event \TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent allows to alter the query builder SQL statement before a list of records is rendered in record lists, such as the List module or an element browser.

Example

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

declare(strict_types=1);

namespace MyVendor\MyExtension\Backend\EventListener;

use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

#[AsEventListener(
    identifier: 'my-extension/backend/modify-database-query-for-record-list',
)]
final readonly class MyEventListener
{
    public function __invoke(ModifyDatabaseQueryForRecordListingEvent $event): void
    {
        $queryBuilder = $event->getQueryBuilder();

        // ... do something ...

        $event->setQueryBuilder($queryBuilder);
    }
}
Copied!

New in version 13.0

API

class ModifyDatabaseQueryForRecordListingEvent
Fully qualified name
\TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent

Use this Event to alter the database query when loading content for a page (usually in the list module) before it is executed.

getQueryBuilder ( )
Returns
\TYPO3\CMS\Core\Database\Query\QueryBuilder
setQueryBuilder ( \TYPO3\CMS\Core\Database\Query\QueryBuilder $queryBuilder)
param $queryBuilder

the queryBuilder

getTable ( )
Returns
string
getPageId ( )
Returns
int
getFields ( )
Returns
array
getFirstResult ( )
Returns
int
getMaxResults ( )
Returns
int
getDatabaseRecordList ( )
Returns
\TYPO3\CMS\Backend\RecordList\DatabaseRecordList