Feature: #99409 - New PSR-14 BeforeLiveSearchFormIsBuiltEvent

See forge#99409

Description

A new PSR-14 event \TYPO3\CMS\Backend\Search\Event\BeforeLiveSearchFormIsBuiltEvent has been added.

To modify the live search form data, the following methods are available:

  • addHint(): Add a single hint.
  • addHints(): Add one or multiple hints.
  • setHints(): Allows to set hints. Can be used to reset or overwrite current hints.
  • getHints(): Returns all hints.
  • getRequest(): Returns the current PSR-7 Request.
  • getSearchDemand(): Returns the SearchDemand, used by the live search.
  • setSearchDemand(): Allows to set a custom SearchDemand object.
  • :php:`getAdditionalViewData(): Returns the additional view data set to be used in the template.
  • :php:`setAdditionalViewData(): Set the additional view data to be used in the template.

Example

The corresponding event listener class:

<?php

namespace MyVendor\MyPackage\Backend\Search\EventListener;

use TYPO3\CMS\Backend\Search\Event\BeforeLiveSearchFormIsBuiltEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

final class BeforeLiveSearchFormIsBuiltEventListener
{
    #[AsEventListener('my-package/backend/search/modify-live-search-form-data')]
    public function __invoke(BeforeLiveSearchFormIsBuiltEvent $event): void
    {
        $event->addHints(...[
            'LLL:EXT:my-package/Resources/Private/Language/locallang.xlf:identifier',
        ]);
    }
}
Copied!

Impact

It's now possible to modify the form data for the backend live search, using the new PSR-14 event BeforeLiveSearchFormIsBuiltEvent.