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

CPS-IT / handlebars / 19095602588

05 Nov 2025 08:18AM UTC coverage: 86.907% (-4.6%) from 91.508%
19095602588

Pull #486

github

web-flow
Merge a32bb4f13 into c153b07af
Pull Request #486: [FEATURE] Introduce data processor to replace markers in processed data

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

916 of 1054 relevant lines covered (86.91%)

5.12 hits per line

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

0.0
/Classes/DataProcessing/ResolveMarkersProcessor.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 CPSIT\Typo3Handlebars\Renderer;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Frontend;
23

24
/**
25
 * Data processor to resolve and replace markers within configured variables.
26
 *
27
 * Example:
28
 * ========
29
 *
30
 * lib {
31
 *   navigation {
32
 *     template = @nav
33
 *     navData {
34
 *       items = ###NAV_ITEMS###
35
 *     }
36
 *   }
37
 * }
38
 *
39
 * page {
40
 *   10 = HANDLEBARSTEMPLATE
41
 *   10 {
42
 *     templateName = @page
43
 *     variables {
44
 *       mainNav < lib.navigation
45
 *     }
46
 *
47
 *     dataProcessing {
48
 *       10 = menu
49
 *       10.as = ###NAV_ITEMS###
50
 *
51
 *       90 = resolve-markers
52
 *       90 {
53
 *         removeNonMatchingMarkers = 1
54
 *       }
55
 *     }
56
 *   }
57
 * }
58
 *
59
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
60
 * @license GPL-2.0-or-later
61
 */
62
#[DependencyInjection\Attribute\AutoconfigureTag('data.processor', ['identifier' => 'resolve-markers'])]
63
final class ResolveMarkersProcessor implements Frontend\ContentObject\DataProcessorInterface
64
{
65
    /**
66
     * @param array<string, mixed> $contentObjectConfiguration
67
     * @param array<string, mixed> $processorConfiguration
68
     * @param array<array-key, mixed> $processedData
69
     * @return array<array-key, mixed>
70
     */
NEW
71
    public function process(
×
72
        Frontend\ContentObject\ContentObjectRenderer $cObj,
73
        array $contentObjectConfiguration,
74
        array $processorConfiguration,
75
        array $processedData,
76
    ): array {
NEW
77
        $pattern = $processorConfiguration['pattern'] ?? null;
×
NEW
78
        $removeNonMatchingMarkers = (bool)($processorConfiguration['removeNonMatchingMarkers'] ?? false);
×
79

NEW
80
        $processor = Renderer\Variables\MarkerBasedValueProcessor::create($pattern);
×
NEW
81
        $processor->replaceMarkers($processedData, $removeNonMatchingMarkers);
×
82

NEW
83
        return $processedData;
×
84
    }
85
}
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