• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TYPO3-Headless / headless / 26440568390

26 May 2026 08:13AM UTC coverage: 72.91%. First build
26440568390

Pull #892

github

web-flow
Merge da0000d78 into fdf45e8bf
Pull Request #892: [BUGFIX] Do not modify external links, fixes for cropping, small optimization backported from 5.x branch

48 of 60 new or added lines in 11 files covered. (80.0%)

1160 of 1591 relevant lines covered (72.91%)

8.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/DataProcessing/ExtractPropertyProcessor.php
1
<?php
2

3
/*
4
 * This file is part of the "headless" Extension for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.md file that was distributed with this source code.
8
 */
9

10
declare(strict_types=1);
11

12
namespace FriendsOfTYPO3\Headless\DataProcessing;
13

14
use Exception;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
17
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
18

19
/**
20
 * Extract a single (maybe nested) property from a given array
21
 *
22
 * Example:
23
 * lib.meta.fields.ogImage = TEXT
24
 * lib.meta.fields.ogImage {
25
 *     dataProcessing {
26
 *         10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
27
 *         ...
28
 *
29
 *         20 = FriendsOfTYPO3\Headless\DataProcessing\ExtractPropertyProcessor
30
 *         20.key = media.publicUrl
31
 *         20.as = media
32
 *     }
33
 * }
34
 */
35
class ExtractPropertyProcessor implements DataProcessorInterface
36
{
37
    /**
38
     * Extract a single (maybe nested) property from a given array
39
     *
40
     * @param ContentObjectRenderer $cObj The content object renderer, which contains data of the content element
41
     * @param array $contentObjectConfiguration The configuration of Content Object
42
     * @param array $processorConfiguration The configuration of this processor
43
     * @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
44
     * @return array the processed data as key/value store
45
     */
46
    public function process(
47
        ContentObjectRenderer $cObj,
48
        array $contentObjectConfiguration,
49
        array $processorConfiguration,
50
        array $processedData
51
    ) {
52
        if (empty($processorConfiguration['as'])) {
×
53
            throw new Exception('Please specify property \'as\'');
×
54
        }
55

56
        if (empty($processorConfiguration['key'])) {
×
57
            throw new Exception('Please specify property \'key\'');
×
58
        }
59

60
        $targetFieldName = (string)$cObj->stdWrapValue(
×
61
            'as',
×
62
            $processorConfiguration
×
63
        );
×
64

65
        $key = GeneralUtility::trimExplode('.', $processorConfiguration['key'], true);
×
66

NEW
67
        $value = $processedData;
×
NEW
68
        foreach ($key as $segment) {
×
NEW
69
            if (!is_array($value)) {
×
NEW
70
                $value = null;
×
NEW
71
                break;
×
72
            }
NEW
73
            $value = $value[$segment] ?? null;
×
74
        }
75

76
        return [
×
NEW
77
            $targetFieldName => $value,
×
78
        ];
×
79
    }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc