-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Reestablish manipulation of EXT:indexed_search query (#5135)
References: TYPO3-Documentation/Changelog-To-Doc#1087 Releases: main, 13.4 Co-authored-by: lina.wolf <lwolf@w-commerce.de>
- Loading branch information
1 parent
ae5e1d6
commit eee5190
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...iOverview/Events/Events/IndexedSearch/BeforeFinalSearchQueryIsExecutedEvent.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.. include:: /Includes.rst.txt | ||
.. index:: Events; BeforeFinalSearchQueryIsExecutedEvent | ||
.. _BeforeFinalSearchQueryIsExecutedEvent: | ||
|
||
===================================== | ||
BeforeFinalSearchQueryIsExecutedEvent | ||
===================================== | ||
|
||
.. versionadded:: 13.4.2 / 14.0 | ||
This event was added as a replacement for the removed hook | ||
`$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['indexed_search']['pi1_hooks']`. | ||
|
||
The PSR-14 :php:`\TYPO3\CMS\IndexedSearch\Event\BeforeFinalSearchQueryIsExecutedEvent` | ||
has been introduced which allows developers to manipulate the (internal) | ||
:php:`\TYPO3\CMS\Core\Database\Query\QueryBuilder` | ||
instance, just before the query gets executed. | ||
|
||
.. important:: | ||
|
||
The provided query (the :php:`\TYPO3\CMS\Core\Database\Query\QueryBuilder` | ||
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. | ||
|
||
.. _BeforeFinalSearchQueryIsExecutedEvent-example: | ||
|
||
Example | ||
======= | ||
|
||
Changing the host of the current request and setting it as canonical: | ||
|
||
.. literalinclude:: _BeforeFinalSearchQueryIsExecutedEvent/_MyEventListener.php | ||
:language: php | ||
:caption: EXT:my_extension/Classes/IndexedSearch/EventListener/MyEventListener.php | ||
|
||
.. _BeforeFinalSearchQueryIsExecutedEvent-api: | ||
|
||
API | ||
=== | ||
|
||
.. include:: /CodeSnippets/Events/IndexedSearch/BeforeFinalSearchQueryIsExecutedEvent.rst.txt |
18 changes: 18 additions & 0 deletions
18
Documentation/ApiOverview/Events/Events/IndexedSearch/Index.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.. include:: /Includes.rst.txt | ||
.. index:: pair: Events; Indexed search | ||
.. _eventlist-indexed-search: | ||
|
||
============== | ||
Indexed search | ||
============== | ||
|
||
The following list contains :ref:`PSR-14 events <EventDispatcher>` | ||
in :composer:`typo3/cms-indexed-search`. | ||
|
||
**Contents:** | ||
|
||
.. toctree:: | ||
:titlesonly: | ||
:glob: | ||
|
||
* |
19 changes: 19 additions & 0 deletions
19
...w/Events/Events/IndexedSearch/_BeforeFinalSearchQueryIsExecutedEvent/_MyEventListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?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'), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Documentation/CodeSnippets/Config/Api/Events/EventsIndexedSearch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
'action' => 'createPhpClassDocs', | ||
'class' => \TYPO3\CMS\IndexedSearch\Event\BeforeFinalSearchQueryIsExecutedEvent::class, | ||
'targetFileName' => 'CodeSnippets/Events/IndexedSearch/BeforeFinalSearchQueryIsExecutedEvent.rst.txt', | ||
'withCode' => false, | ||
], | ||
]; |
17 changes: 17 additions & 0 deletions
17
...CodeSnippets/Events/IndexedSearch/BeforeFinalSearchQueryIsExecutedEvent.rst.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.. Generated by https://github.com/TYPO3-Documentation/t3docs-codesnippets | ||
.. php:namespace:: TYPO3\CMS\IndexedSearch\Event | ||
.. php:class:: BeforeFinalSearchQueryIsExecutedEvent | ||
Listeners are able to manipulate the QueryBuilder before the search query gets executed | ||
|
||
.. php:attr:: queryBuilder | ||
:public: | ||
|
||
.. php:attr:: searchWords | ||
:readonly: | ||
:public: | ||
|
||
.. php:attr:: freeIndexUid | ||
:readonly: | ||
:public: |