|
4 | 4 |
|
5 | 5 | namespace Kanti\ServerTiming\DataProcessor; |
6 | 6 |
|
7 | | -use TYPO3\CMS\Core\Utility\ArrayUtility; |
| 7 | +use TYPO3\CMS\Core\Information\Typo3Version; |
8 | 8 | use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor; |
9 | | -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
10 | 9 |
|
11 | | -final class XClassContentDataProcessor extends ContentDataProcessor |
12 | | -{ |
13 | | - /** |
14 | | - * @param array<array-key, mixed> $configuration |
15 | | - * @param array<array-key, mixed> $variables |
16 | | - * @return array<array-key, mixed> |
17 | | - */ |
18 | | - public function process(ContentObjectRenderer $cObject, array $configuration, array $variables) |
19 | | - { |
20 | | - $processors = $configuration['dataProcessing.'] ?? []; |
21 | | - if (!$processors) { |
22 | | - return $variables; |
23 | | - } |
24 | | - |
25 | | - $processorKeys = ArrayUtility::filterAndSortByNumericKeys($processors); |
26 | | - $index = 1; |
27 | | - $newDataProcessing = []; |
28 | | - foreach ($processorKeys as $key) { |
29 | | - $processorClassOrAlias = $processors[$key]; |
30 | | - |
31 | | - $uniqId = uniqId(); |
32 | | - |
33 | | - $newDataProcessing[$index] = TrackingDataProcessor::class; |
34 | | - $newDataProcessing[$index . '.'] = ['key' => $key, 'processorOrAlias' => $processorClassOrAlias, 'type' => 'start', 'id' => $uniqId, 'for' => $cObject->getCurrentTable() . ':' . $cObject->data['uid']]; |
35 | | - $index++; |
36 | | - $newDataProcessing[$index] = $processorClassOrAlias; |
37 | | - $newDataProcessing[$index . '.'] = $processors[$key . '.'] ?? []; |
38 | | - $index++; |
39 | | - $newDataProcessing[$index] = TrackingDataProcessor::class; |
40 | | - $newDataProcessing[$index . '.'] = ['type' => 'stop', 'id' => $uniqId]; |
41 | | - $index++; |
42 | | - } |
| 10 | +// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses |
43 | 11 |
|
44 | | - $configuration['dataProcessing.'] = $newDataProcessing; |
45 | | - |
46 | | - return parent::process($cObject, $configuration, $variables); |
| 12 | +if ((new Typo3Version())->getMajorVersion() <= 13) { |
| 13 | + final class XClassContentDataProcessor extends ContentDataProcessor |
| 14 | + { |
| 15 | + use XClassContentDataProcessorTrait; |
| 16 | + } |
| 17 | +} else { |
| 18 | + final readonly class XClassContentDataProcessor extends ContentDataProcessor |
| 19 | + { |
| 20 | + use XClassContentDataProcessorTrait; |
47 | 21 | } |
48 | 22 | } |
0 commit comments