Feature: #99409 - New PSR-14 BeforeLiveSearchFormIsBuiltEvent
See forge#99409
Description
A new PSR-14 event
\TYPO3\
has been added.
To modify the live search form data, the following methods are available:
add
: Add a single hint.Hint () add
: Add one or multiple hints.Hints () set
: Allows to set hints. Can be used to reset or overwrite current hints.Hints () get
: Returns all hints.Hints () get
: Returns the current PSR-7 Request.Request () get
: Returns theSearch Demand () Search
, used by the live search.Demand set
: Allows to set a customSearch Demand () Search
object.Demand - :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.
Note
set
becomes handy to provide additional data to
the template without the need to cross class ("xclass") the controller. The
additional view data can be used in a overridden backend template of the
live search form.
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
Before
.