Issue Feature Closed

#99323PSR-14 Event for manipulating records in ContentContentObject.php->render()

Joey Bouten 12/09/22, 10:24 updated 01/30/24, 08:27

Description

Due to our use of `mod.web_layout.allowInconsistentLanguageHandling = 1` we encountered an issue that the sorting of the content elements in the front-end differs from the sorting in the backend.
Since we use strict mode incombination with allowing non-connected content elements in languages the sortings fails since it is always based on the sorting of the default language.

We fixed this in V10 by introducing a PSR-14 Event with-in a XClass.
Since `allowInconsistentLanguageHandling` is not officially supported by the core we do not expect a bugfix.
That is why we would like to introduce a PSR-14 Event in the render function like this.
So we can use the event to re-sort the elements with an asort.

......
do {
    $records = $this->cObj->getRecords($conf['table'], $conf['select.']);

    // START: THIS WAS CHANGED IN THE XCLASS IN THIS FUNCTION
    $eventDispatcher = GeneralUtility::makeInstance(EventDispatcher::class);
    $event = $eventDispatcher->dispatch(
        new ModifyRecordsAfterFetchingContentEvent($records, $conf)
    );
    $records = $event->getRecords();
    // END: THIS WAS CHANGED IN THE XCLASS IN THIS FUNCTION

    $cobjValue = '';
    if (!empty($records)) {
        $this->getTimeTracker()->setTSlogMessage('NUMROWS: ' . count($records));
......

I will provide a PR in the following days.

Reviews 2