-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApplyFieldDataTransformations.php
More file actions
43 lines (35 loc) · 1.36 KB
/
ApplyFieldDataTransformations.php
File metadata and controls
43 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace FriendsOfTYPO3\Interest\DataHandling\Operation\Event\Handler;
use FriendsOfTYPO3\Interest\DataHandling\Operation\DeleteRecordOperation;
use FriendsOfTYPO3\Interest\DataHandling\Operation\Event\AbstractRecordOperationEvent;
use FriendsOfTYPO3\Interest\DataHandling\Operation\Event\RecordOperationEventHandlerInterface;
/**
* Simply sets the language in the ContentObjectRenderer's data array.
*/
class ApplyFieldDataTransformations implements RecordOperationEventHandlerInterface
{
/**
* @inheritDoc
*/
public function __invoke(AbstractRecordOperationEvent $event): void
{
if ($event->getRecordOperation() instanceof DeleteRecordOperation) {
return;
}
$recordOperation = $event->getRecordOperation();
$settings = $recordOperation->getSettings();
foreach (
$settings['transformations.'][$recordOperation->getTable() . '.'] ?? [] as $fieldName => $configuration
) {
$fieldName = substr((string)$fieldName, 0, -1);
$recordOperation->setDataFieldForDataHandler(
$fieldName,
$recordOperation->getContentObjectRenderer()->stdWrap(
$recordOperation->getDataForDataHandler()[$fieldName] ?? '',
$configuration
)
);
}
}
}