---
title: "Feature: #105827 - New PSR-14 ModifyConstraintsForLiveSearchEvent"
manual: "TYPO3 Core Changelog"
version: "main"
permalink: "https://docs.typo3.org/permalink/changelog:feature-105827-1751912675"
source: "Changelog/14.2/Feature-105827-NewPSR-14ModifyConstraintsForLiveSearchEvent.rst"
typo3-version: "14.2"
typo3-major: 14
type: "feature"
issue: 105827
forge: "https://forge.typo3.org/issues/105827"
tags: ["Backend", "PHP-API", "ext:backend"]
rendered: "2026-09-20T18:31:11+00:00"
---

# Feature: #105827 - New PSR-14 ModifyConstraintsForLiveSearchEvent {#feature-105827-1751912675}

See [forge#105827](https://forge.typo3.org/issues/105827), [forge#105833](https://forge.typo3.org/issues/105833), [forge#93494](https://forge.typo3.org/issues/93494)

## Description {#description}

A new PSR-14 event
`\TYPO3\CMS\Backend\Search\Event\ModifyConstraintsForLiveSearchEvent`
has been added to TYPO3 Core. This event is dispatched in the
`LiveSearch` class and allows
extensions to modify the
`CompositeExpression`
constraints collected in an array before execution.

This makes it possible to add additional constraints to the main query
constraints, combined with a logical `OR`. These constraints could
not previously be accessed by the existing event
`ModifyQueryForLiveSearchEvent`.

The event provides the following methods:

-   `getConstraints()`: Returns the current array of query constraints
    (composite expressions).
-   `addConstraint()`: Adds a single constraint.
-   `addConstraints()`: Adds multiple new constraints.
-   `getTableName()`: Returns the table for which the query is executed
    (for example, `pages` or `tt_content`).
-   `getSearchDemand()`: Returns the search demand.

> [!TIP]
> **Hint**
>
> Constraints are intended to be added only. This ensures that
> security-related mandatory constraints added by Core or extensions cannot
> be negatively affected. For this reason, there is no way to remove a
> constraint after it has been added.

## Example {#example}

The corresponding event listener class:

```php
<?php

namespace Vendor\MyPackage\Backend\EventListener;

use TYPO3\CMS\Backend\Search\Event\ModifyConstraintsForLiveSearchEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Database\ConnectionPool;

final readonly class PageRecordProviderEnhancedSearch
{
    public function __construct(
        private ConnectionPool $connectionPool,
    ) {}

    #[AsEventListener('my-package/livesearch-enhanced')]
    public function __invoke(
        ModifyConstraintsForLiveSearchEvent $event,
    ): void {
        if ($event->getTableName() !== 'pages') {
            return;
        }

        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
        // Add a constraint so that pages marked with "show_in_all_results=1"
        // will always be shown.
        $constraints[] = $queryBuilder->expr()->eq(
            'show_in_all_results',
            1,
        );

        $event->addConstraints(...$constraints);
    }
}
```

Core itself uses this event to allow searching for frontend URIs in the
backend page tree.

## Impact {#impact}

A new PSR-14 event is now available for adding constraints to the live search
query. These constraints are combined with a logical `OR`.
