ModifyVersionDifferencesEvent
New in version 12.0
This PSR-14 event replaces the
$GLOBALS
hook.
The PSR-14 event \TYPO3\
can be used to modify the version differences data, used for the display in the
Web > Workspaces backend module. Those data can be accessed
with the get
method and updated using the
set
method.
Example
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Workspaces\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/modify-version-differences'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Workspaces\EventListener;
use TYPO3\CMS\Core\Utility\DiffUtility;
use TYPO3\CMS\Workspaces\Event\ModifyVersionDifferencesEvent;
final class MyEventListener
{
public function __construct(private readonly DiffUtility $diffUtility)
{
$this->diffUtility->stripTags = false;
}
public function __invoke(ModifyVersionDifferencesEvent $event): void
{
$differences = $event->getVersionDifferences();
foreach ($differences as $key => $difference) {
if ($difference['field'] === 'my_test_field') {
$differences[$key]['content'] = $this->diffUtility->makeDiffDisplay('a', 'b');
}
}
$event->setVersionDifferences($differences);
}
}
API
- class ModifyVersionDifferencesEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Workspaces\ Event\ Modify Version Differences Event
Listeners to this event will be able to modify the differences of versioned records
- getVersionDifferences ( )
-
Get the version differences.
This array contains the differences of each field with the following keys:
- field: The corresponding field name
- label: The corresponding field label
- content: The field values difference
- Return description
-
String, label: string, content: string}>
- Returns
-
list<array
{field:
- setVersionDifferences ( array $versionDifferences)
-
Modifies the version differences data
- param $versionDifferences
-
the versionDifferences