Data Processing
Content Blocks is based on the new Record API
in TYPO3 v13. As soon as a Record
is created
and enriched, it is immutable. This means the standard way of data processing
via custom DataProcessors
will not work anymore, if it was based on manipulating the
$processed
array.
Note
It is still possible to create a new variable alongside data
.
The new recommended way adding custom logic via PHP is to use the new PSR-14 RecordCreationEvent. This event has the advantage that it is always triggered as soon as a Record is created, independent of frontend or backend context or even in scenarios where the Record is part of a nested structure.
Example
The event listener class, using the PHP attribute #
for
registration, creates a Coordinates
object based on the field value of
the coordinates
field for the custom maps
content type.
final class RecordCreationEventListener
{
#[AsEventListener]
public function __invoke(\TYPO3\CMS\Core\Domain\Event\RecordCreationEvent $event): void
{
$rawRecord = $event->getRawRecord();
if ($rawRecord->getMainType() === 'tt_content' && $rawRecord->getRecordType() === 'maps' && $event->hasProperty('coordinates')) {
$event->setProperty(
'coordinates',
new Coordinates($event->getProperty('coordinates'))
);
}
}
}