ModifyQueryBeforeFetchingObjectDataEvent 

The PSR-14 event \TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectDataEvent is fired before the storage backend is asked for results from a given query.

Example: Ignore the storage page for some models 

The example disables the respect storage page flag for the given types (models). This can be helpful if you are using bounded contexts and therefore have multiple repository and model classes. By using an event listener, this setting is centralized and does not to be repeated in each repository class.

EXT:my_extension/Classes/Extbase/EventListener/DisableRespectStoragePage.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Extbase\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectDataEvent;

#[AsEventListener(
  identifier: 'my-extension/disabled-respect-storage-page',
)]
final readonly class DisableRespectStoragePage
{
  private const TYPES = [
    \MyVendor\MyExtension\Domain\Model\List\MyRecord::class,
    \MyVendor\MyExtension\Domain\Model\Show\MyRecord::class,
  ];

  public function __invoke(ModifyQueryBeforeFetchingObjectDataEvent $event): void
  {
    // Only apply it to the given types (models)
    if (! \in_array($event->getQuery()->getType(), self::TYPES, true)) {
      return;
    }

    $querySettings = $event->getQuery()->getQuerySettings();
    $querySettings->setRespectStoragePage(false);
  }
}
Copied!

API 

final class ModifyQueryBeforeFetchingObjectDataEvent
Fully qualified name
\TYPO3\CMS\Extbase\Event\Persistence\ModifyQueryBeforeFetchingObjectDataEvent

Event which is fired before the storage backend is asked for results from a given query.

getQuery()
Returns
\TYPO3\CMS\Extbase\Persistence\QueryInterface
setQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query)
param $query

the query