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

CPS-IT / handlebars / 28575318793

02 Jul 2026 08:09AM UTC coverage: 86.951% (-2.7%) from 89.609%
28575318793

Pull #605

github

web-flow
Merge 23fc6cefa into fe28bf1ca
Pull Request #605: [FEATURE] Implement `object-access` data processor

3 of 53 new or added lines in 3 files covered. (5.66%)

1466 of 1686 relevant lines covered (86.95%)

6.86 hits per line

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

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

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3Handlebars\DataProcessing;
19

20
use Psr\Log;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Extbase;
23
use TYPO3\CMS\Frontend;
24

25
/**
26
 * Data processor to access a given object by a given property path.
27
 *
28
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
29
 * @license GPL-2.0-or-later
30
 */
31
#[DependencyInjection\Attribute\AutoconfigureTag('data.processor', ['identifier' => 'object-access'])]
32
final readonly class ObjecAccessProcessor implements Frontend\ContentObject\DataProcessorInterface
33
{
NEW
34
    public function __construct(
×
35
        private Log\LoggerInterface $logger,
36
        private Frontend\ContentObject\ContentDataProcessor $contentDataProcessor,
NEW
37
    ) {}
×
38

39
    /**
40
     * @param array<string, mixed> $contentObjectConfiguration
41
     * @param array<string, mixed> $processorConfiguration
42
     * @param array<string|int, mixed> $processedData
43
     * @return array<string|int, mixed>
44
     * @throws Extbase\Reflection\Exception\PropertyNotAccessibleException
45
     * @throws Frontend\ContentObject\Exception\ContentRenderingException
46
     */
NEW
47
    public function process(
×
48
        Frontend\ContentObject\ContentObjectRenderer $cObj,
49
        array $contentObjectConfiguration,
50
        array $processorConfiguration,
51
        array $processedData,
52
    ): array {
NEW
53
        $collection = new DataSource\DataSourceCollection();
×
NEW
54
        $collection->set(DataSource\DataSource::ContentObjectRenderer, $cObj->data);
×
NEW
55
        $collection->set(DataSource\DataSource::ContentObjectConfiguration, $contentObjectConfiguration);
×
NEW
56
        $collection->set(DataSource\DataSource::ProcessedData, $processedData);
×
NEW
57
        $collection->set(DataSource\DataSource::ProcessorConfiguration, $processorConfiguration);
×
58

NEW
59
        $objectSource = $collection->resolve('object', DataSource\DataSource::ProcessorConfiguration);
×
60

61
        // Early return if object source is not configured
NEW
62
        if (!is_string($objectSource) || $objectSource === '') {
×
NEW
63
            $this->logger->warning(
×
NEW
64
                'Invalid object source configured for "object-access" data processor while processing {table}:{uid}.',
×
NEW
65
                [
×
NEW
66
                    'table' => $cObj->getCurrentTable(),
×
NEW
67
                    'uid' => $collection->resolveCurrentUid(),
×
NEW
68
                ],
×
NEW
69
            );
×
70

NEW
71
            return $processedData;
×
72
        }
73

74
        /** @var string $as */
NEW
75
        $as = $collection->resolve('as', DataSource\DataSource::ProcessorConfiguration, 'result');
×
NEW
76
        $path = $collection->resolve('path', DataSource\DataSource::ProcessorConfiguration);
×
NEW
77
        $object = $collection->resolve($objectSource);
×
78

79
        // Early return if either object or path is not valid
NEW
80
        if (!is_string($path) || !is_object($object)) {
×
NEW
81
            $this->logger->warning(
×
NEW
82
                'Invalid object or path configured for "object-access" data processor while processing {table}:{uid}.',
×
NEW
83
                [
×
NEW
84
                    'table' => $cObj->getCurrentTable(),
×
NEW
85
                    'uid' => $collection->resolveCurrentUid(),
×
NEW
86
                ],
×
NEW
87
            );
×
88

NEW
89
            return $processedData;
×
90
        }
91

92
        // Early return if object path is not gettable
NEW
93
        if (!Extbase\Reflection\ObjectAccess::isPropertyGettable($object, $path)) {
×
NEW
94
            $this->logger->warning(
×
NEW
95
                'Configured object path "{path}" is not gettable for object at "{objectSource}" while processing {table}:{uid}.',
×
NEW
96
                [
×
NEW
97
                    'path' => $path,
×
NEW
98
                    'objectSource' => $objectSource,
×
NEW
99
                    'table' => $cObj->getCurrentTable(),
×
NEW
100
                    'uid' => $collection->resolveCurrentUid(),
×
NEW
101
                ],
×
NEW
102
            );
×
103

NEW
104
            return $processedData;
×
105
        }
106

107
        // Resolve property
NEW
108
        $processedData[$as] = Extbase\Reflection\ObjectAccess::getProperty($object, $path);
×
109

110
        // Process additional data processors
NEW
111
        if (is_array($processedData[$as])) {
×
NEW
112
            $processedData[$as] = $this->contentDataProcessor->process($cObj, $processorConfiguration, $processedData[$as]);
×
113
        }
114

NEW
115
        return $processedData;
×
116
    }
117
}
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