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

CPS-IT / handlebars-forms / 22348558151

24 Feb 2026 11:19AM UTC coverage: 0.0%. Remained the same
22348558151

push

github

eliashaeussler
[TASK] Wrap renderable VH invocations with `formvh:renderRenderable` VH

0 of 23 new or added lines in 9 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 499 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/Domain/Renderable/ViewModel/AbstractViewModelBuilder.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\Domain\Renderable\ViewModel;
19

20
use CPSIT\Typo3HandlebarsForms\Fluid\ViewHelperInvoker;
21
use TYPO3\CMS\Fluid;
22
use TYPO3\CMS\Form;
23

24
/**
25
 * AbstractViewModelBuilder
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 *
30
 * @template T of Form\Domain\Model\Renderable\RootRenderableInterface
31
 * @implements ViewModelBuilder<T>
32
 */
33
abstract class AbstractViewModelBuilder implements ViewModelBuilder
34
{
35
    /**
36
     * @var list<non-empty-string>
37
     */
38
    protected array $supportedTypes = [];
39

40
    public function __construct(
×
41
        protected readonly ViewHelperInvoker $viewHelperInvoker,
42
    ) {}
×
43

NEW
44
    public function build(
×
45
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
46
        Fluid\Core\Rendering\RenderingContext $renderingContext,
47
    ): ViewModel {
NEW
48
        $result = $this->viewHelperInvoker->invoke(
×
NEW
49
            $renderingContext,
×
NEW
50
            Form\ViewHelpers\RenderRenderableViewHelper::class,
×
NEW
51
            ['renderable' => $renderable],
×
NEW
52
            function () use ($renderable, $renderingContext, &$viewModel) {
×
NEW
53
                $viewModel = $this->renderRenderable($renderable, $renderingContext);
×
54

NEW
55
                return '';
×
NEW
56
            },
×
NEW
57
        );
×
58

NEW
59
        if ($viewModel instanceof ViewModel) {
×
NEW
60
            return $viewModel;
×
61
        }
62

NEW
63
        return new ViewModel($renderingContext, $result->content, $result->tag);
×
64
    }
65

66
    /**
67
     * @param T $renderable
68
     */
NEW
69
    protected function renderRenderable(
×
70
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
71
        Fluid\Core\Rendering\RenderingContext $renderingContext,
72
    ): ?ViewModel {
NEW
73
        return null;
×
74
    }
75

UNCOV
76
    public function supports(Form\Domain\Model\Renderable\RootRenderableInterface $renderable): bool
×
77
    {
78
        return in_array($renderable->getType(), $this->supportedTypes, true);
×
79
    }
80

81
    /**
82
     * @param T $renderable
83
     * @return array<string, mixed>
84
     */
85
    protected function renderAdditionalAttributes(
×
86
        Fluid\Core\Rendering\RenderingContext $renderingContext,
87
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
88
    ): array {
89
        $content = $this->translateElementProperty(
×
90
            $renderingContext,
×
91
            $renderable,
×
92
            'fluidAdditionalAttributes',
×
93
        );
×
94

95
        if (!is_array($content)) {
×
96
            return [];
×
97
        }
98

99
        return $content;
×
100
    }
101

102
    protected function translateElementProperty(
×
103
        Fluid\Core\Rendering\RenderingContext $renderingContext,
104
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
105
        string $property,
106
    ): mixed {
107
        $result = $this->viewHelperInvoker->invoke(
×
108
            $renderingContext,
×
109
            Form\ViewHelpers\TranslateElementPropertyViewHelper::class,
×
110
            [
×
111
                'element' => $renderable,
×
112
                'property' => $property,
×
113
            ],
×
114
        );
×
115

116
        return $result->content;
×
117
    }
118
}
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