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

CPS-IT / handlebars-forms / 23538427258

25 Mar 2026 11:21AM UTC coverage: 0.728% (-0.03%) from 0.756%
23538427258

push

github

web-flow
Merge pull request #16 from CPS-IT/feature/fluid-proxy

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

1 existing line in 1 file now uncovered.

7 of 962 relevant lines covered (0.73%)

0.03 hits per line

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

0.0
/Classes/ContentObject/RenderablesContentObject.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
use TYPO3\CMS\Fluid;
23
use TYPO3\CMS\Form;
24

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

36
    /**
37
     * @param iterable<Domain\Renderable\ViewModel\ViewModelBuilder<Form\Domain\Model\Renderable\RootRenderableInterface>> $viewModelBuilders
38
     */
39
    public function __construct(
×
40
        #[DependencyInjection\Attribute\AutowireIterator('handlebars_forms.view_model_builder')]
41
        private readonly iterable $viewModelBuilders,
42
        private readonly PassthroughContentObject $passthroughContentObject,
UNCOV
43
    ) {}
×
44

45
    /**
46
     * @return list<mixed>
47
     */
48
    protected function resolve(array $configuration, Context\ValueResolutionContext $context): array
×
49
    {
50
        $renderable = $context->renderable;
×
51
        $processedRenderables = [];
×
52

53
        // Use current page as base renderable if we're on root form context
54
        if ($renderable instanceof Form\Domain\Runtime\FormRuntime) {
×
55
            $renderable = $renderable->getCurrentPage() ?? $renderable;
×
56
        }
57

58
        // Fetch renderables from base renderable. On default sections (e.g. pages), this reflects
59
        // all direct children. On all other composite renderables, this reflects all renderables
60
        // recursively (including deeply nested rebderables). If we have a non-composite base
61
        // renderable in place, we do nothing since this value resolver only handles composite renderables.
62
        if ($renderable instanceof Form\Domain\Model\FormElements\AbstractSection) {
×
63
            $renderables = $renderable->getElements();
×
64
        } elseif ($renderable instanceof Form\Domain\Model\Renderable\CompositeRenderableInterface) {
×
65
            $renderables = $renderable->getRenderablesRecursively();
×
66
        } else {
67
            $renderables = [];
×
68
        }
69

70
        foreach ($renderables as $index => $child) {
×
71
            if (!$child->isEnabled()) {
×
72
                continue;
×
73
            }
74

NEW
75
            if (!array_key_exists($child->getType() . '.', $configuration)) {
×
NEW
76
                $processedRenderables[] = $this->passthroughContentObject->render();
×
77

NEW
78
                continue;
×
79
            }
80

NEW
81
            $childConfiguration = $configuration[$child->getType() . '.'];
×
82

83
            if (is_array($childConfiguration)) {
×
84
                $childViewModel = $this->buildViewModel($child, $context->viewModel->renderingContext);
×
85
            } else {
86
                $childConfiguration = [];
×
87
                $childViewModel = new Domain\Renderable\ViewModel\ViewModel($context->viewModel->renderingContext);
×
88
            }
89

90
            if ($this->cObj !== null) {
×
91
                $this->cObj->data[self::RENDERABLE_INDEX_IDENTIFIER] = $index;
×
92
            }
93

94
            try {
95
                $processedChild = $context->process($childConfiguration, $child, $childViewModel);
×
96
            } finally {
97
                if ($this->cObj !== null) {
×
98
                    unset($this->cObj->data[self::RENDERABLE_INDEX_IDENTIFIER]);
×
99
                }
100
            }
101

102
            if ($processedChild !== null) {
×
103
                $processedRenderables[] = $processedChild;
×
104
            }
105
        }
106

107
        return $processedRenderables;
×
108
    }
109

110
    private function buildViewModel(
×
111
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
112
        Fluid\Core\Rendering\RenderingContext $renderingContext,
113
    ): Domain\Renderable\ViewModel\ViewModel {
114
        foreach ($this->viewModelBuilders as $viewModelBuilder) {
×
115
            if ($viewModelBuilder->supports($renderable)) {
×
116
                return $viewModelBuilder->build($renderable, $renderingContext);
×
117
            }
118
        }
119

120
        return new Domain\Renderable\ViewModel\ViewModel($renderingContext);
×
121
    }
122
}
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