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

CPS-IT / handlebars-forms / 23132770286

16 Mar 2026 07:34AM UTC coverage: 0.0%. Remained the same
23132770286

Pull #10

github

web-flow
Merge c6350c8ec into fdb00737e
Pull Request #10: [FEATURE] Convert value resolvers to context-aware content objects

0 of 88 new or added lines in 11 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

0 of 696 relevant lines covered (0.0%)

0.0 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
    /**
35
     * @param iterable<Domain\Renderable\ViewModel\ViewModelBuilder<Form\Domain\Model\Renderable\RootRenderableInterface>> $viewModelBuilders
36
     */
37
    public function __construct(
×
38
        #[DependencyInjection\Attribute\AutowireIterator('handlebars_forms.view_model_builder')]
39
        private readonly iterable $viewModelBuilders,
40
    ) {}
×
41

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

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

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

67
        foreach ($renderables as $child) {
×
68
            if (!$child->isEnabled()) {
×
69
                continue;
×
70
            }
71

NEW
72
            $childConfiguration = $configuration[$child->getType() . '.'] ?? null;
×
73

74
            if (is_array($childConfiguration)) {
×
NEW
75
                $childViewModel = $this->buildViewModel($child, $context->viewModel->renderingContext);
×
76
            } else {
77
                $childConfiguration = [];
×
NEW
78
                $childViewModel = new Domain\Renderable\ViewModel\ViewModel($context->viewModel->renderingContext, null);
×
79
            }
80

81
            $processedChild = $context->process($childConfiguration, $child, $childViewModel);
×
82

83
            if ($processedChild !== null) {
×
84
                $processedRenderables[] = $processedChild;
×
85
            }
86
        }
87

88
        return $processedRenderables;
×
89
    }
90

91
    private function buildViewModel(
×
92
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
93
        Fluid\Core\Rendering\RenderingContext $renderingContext,
94
    ): Domain\Renderable\ViewModel\ViewModel {
95
        foreach ($this->viewModelBuilders as $viewModelBuilder) {
×
96
            if ($viewModelBuilder->supports($renderable)) {
×
97
                return $viewModelBuilder->build($renderable, $renderingContext);
×
98
            }
99
        }
100

101
        return new Domain\Renderable\ViewModel\ViewModel($renderingContext, null);
×
102
    }
103
}
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