BeforeFinalSearchQueryIsExecutedEvent
New in version 13.4.2 / 14.0
This event was added as a replacement for the removed hook
$GLOBALS
.
The PSR-14 \TYPO3\
has been introduced which allows developers to manipulate the (internal)
\TYPO3\
instance, just before the query gets executed.
Important
The provided query (the \TYPO3\
instance) is controlled by the
TYPO3 Core and is not considered public API. Therefore, developers using this
event need to keep track of underlying changes by TYPO3. Such changes might
be further performance improvements to the query or changes to the
database schema in general.
Example
Changing the host of the current request and setting it as canonical:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\IndexedSearch\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\IndexedSearch\Event\BeforeFinalSearchQueryIsExecutedEvent;
final readonly class EventListener
{
#[AsEventListener(identifier: 'manipulate-search-query')]
public function beforeFinalSearchQueryIsExecuted(BeforeFinalSearchQueryIsExecutedEvent $event): void
{
$event->queryBuilder->andWhere(
$event->queryBuilder->expr()->eq('some_column', 'some_value'),
);
}
}