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

CPS-IT / handlebars-forms / 23843726511

01 Apr 2026 10:17AM UTC coverage: 0.592% (-0.001%) from 0.593%
23843726511

Pull #20

github

web-flow
Merge 6a6ed8c43 into f34c7bc8f
Pull Request #20: [TASK] Use register from TSFE to populate child information

0 of 5 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

7 of 1182 relevant lines covered (0.59%)

0.02 hits per line

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

0.0
/Classes/ContentObject/ChildrenContentObject.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars_forms".
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\Typo3HandlebarsForms\ContentObject;
19

20
use CPSIT\Typo3HandlebarsForms\Domain;
21
use Symfony\Component\DependencyInjection;
22

23
/**
24
 * ChildrenContentObject
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 */
29
#[DependencyInjection\Attribute\AutoconfigureTag('frontend.contentobject', ['identifier' => 'HBS_CHILDREN'])]
30
final class ChildrenContentObject extends AbstractHandlebarsFormsContentObject
31
{
32
    private const IDENTIFIER_COUNT = 'HBS_CHILDREN_COUNT';
33
    private const IDENTIFIER_CURRENT = 'HBS_CHILDREN_CURRENT';
34

35
    /**
36
     * @return list<mixed>|null
37
     */
38
    protected function resolve(array $configuration, Context\ValueResolutionContext $context): ?array
×
39
    {
40
        if (!($context->viewModel instanceof Domain\ViewModel\CompositeViewModel)) {
×
41
            return null;
×
42
        }
43

44
        $children = $context->viewModel->getChildren();
×
45

46
        if ($children === []) {
×
47
            return null;
×
48
        }
49

50
        $processedValue = [];
×
51

52
        // Add children count to TSFE register
53
        // @todo Use $this->request->getAttribute('frontend.register.stack') in TYPO3 v14
NEW
54
        $tsfe = $this->getTypoScriptFrontendController();
×
NEW
55
        $tsfe->register[self::IDENTIFIER_COUNT] = count($children);
×
56

57
        foreach ($children as $index => $childViewModel) {
×
58
            // Add current child index to TSFE register
NEW
59
            $tsfe->register[self::IDENTIFIER_CURRENT] = $index;
×
60

61
            try {
62
                $processedValue[] = $context->process($configuration, viewModel: $childViewModel);
×
63
            } finally {
NEW
64
                unset($tsfe->register[self::IDENTIFIER_CURRENT]);
×
65
            }
66
        }
67

NEW
68
        unset($tsfe->register[self::IDENTIFIER_COUNT]);
×
69

UNCOV
70
        return $processedValue;
×
71
    }
72
}
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