Feature: #98426 - New PSR-14 event AfterRecordSummaryForLocalizationEvent

See forge#98426

Description

A new PSR-14 event \TYPO3\CMS\Backend\Controller\Event\AfterRecordSummaryForLocalizationEvent has been added to TYPO3 Core. This event is fired in the \TYPO3\CMS\Backend\Controller\Page\RecordSummaryForLocalization class and allows extensions to modify the payload of the JsonResponse in the getRecordLocalizeSummary method.

The event features the following methods:

  • getColumns(): Returns the current $columns array

  • getRecords(): Returns the current $records array

  • setColumns(): Sets the current $columns array

  • setRecords(): Sets the current $records array

Registration of the event in your extension's Services.yaml:

MyVendor\MyPackage\EventListener\AfterRecordSummaryForLocalizationEventListener:
  tags:
    - name: event.listener
      identifier: 'my-package/after-record-summary-for-localization-event-listener'

The corresponding event listener class:

use TYPO3\CMS\Backend\Controller\Event\AfterRecordSummaryForLocalizationEvent;

final class AfterRecordSummaryForLocalizationEventListener
{
    public function __invoke(AfterRecordSummaryForLocalizationEvent $event): void
    {
        // Get current records
        $records = $event->getRecords();

        // Remove or add $records available for translation

        // Set new records
        $event->setRecords($records);

        // Get current columns
        $columns = $event->getColumns();

        // Remove or add $columns available for translation

        // Set new columns
        $event->setColumns($columns);
    }
}

Impact

The getRecordLocalizeSummary method is called in the translation process, when displaying records and columns to translate. It is now possible to use a new PSR-14 event that can modify the $columns and $records which are available for translation.