[BUGFIX] Deprecate broken buildQueryParameters hook
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Feature-83740-CleanupOfAbstractRecordListBreaksHook.rst
1 .. include:: ../../Includes.txt
2
3 ===========================================================
4 Feature: #83740 - Cleanup of AbstractRecordList breaks hook
5 ===========================================================
6
7 See :issue:`83740`
8
9 Description
10 ===========
11
12 A new hook in :php:`DatabaseRecordList` and :php:`PageLayoutView` allows modify the current database query.
13
14 Register the hook via
15
16 * php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['modifyQuery']`
17 * php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Backend\View\PageLayoutView::class]['modifyQuery']`
18
19 in the extensions :file:`ext_localconf.php` file.
20
21 Example
22 =======
23
24 An example implementation could look like this:
25
26 :file:`EXT:my_site/ext_localconf.php`
27
28 .. code-block:: php
29
30    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class]['modifyQuery'][1313131313] =
31       \MyVendor\MySite\Hooks\DatabaseRecordListHook::class . '->modifyQuery';
32
33
34 :file:`EXT:my_site/Classes/Hooks/DatabaseRecordListHook.php`
35
36 .. code-block:: php
37
38    namespace MyVendor\MySite\Hooks;
39
40    class DatabaseRecordListHook
41    {
42       public function modifyQuery(
43          array $parameters,
44          string $table,
45          int $pageId,
46          array $additionalConstraints,
47          array $fieldList,
48          \TYPO3\CMS\Core\Database\Query\QueryBuilder $queryBuilder
49       ) {
50          // modify $queryBuilder
51       }
52    }
53
54 .. index:: Backend, Database, PHP-API