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

TYPO3-Headless / headless / 11562775396

28 Oct 2024 09:15PM UTC coverage: 72.782% (+4.8%) from 67.995%
11562775396

push

github

web-flow
[BETA][FEATURE] Add TYPO3 v13 compatibility (#778)

* [FEATURE] Add TYPO3 v13 compatibility
- adjust tests for T3v13

* [TASK] Improve tests for v13 LTS & PHPUnit v11

* [BUGFIX] Generate proper frontend url for hreflangs

* [TASK] Introduce HeadlessVersion
TYPO3's Core inspired simple utility to provide small helper to tackle code adjusting for different versions of ext:headless

* [TASK] Set version 4.5.0

* [TASK] Adjusting README

* [BUGFIX] Call parent properly in CLI context

* [BUGFIX] Fix potential warnings

* [BUGFIX] Do not try to import on v12 not existing class

1 of 1 new or added line in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

1083 of 1488 relevant lines covered (72.78%)

8.4 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

67
        // Extract (nested) property
68
        do {
69
            $processedData = $processedData[array_shift($key)] ?? null;
×
70
        } while (count($key));
×
71

72
        return [
×
73
            $targetFieldName => $processedData,
×
74
        ];
×
75
    }
76
}
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

© 2025 Coveralls, Inc