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

CPS-IT / handlebars-forms / 23788866234

31 Mar 2026 08:52AM UTC coverage: 0.659% (-0.06%) from 0.72%
23788866234

push

github

web-flow
Merge pull request #18 from CPS-IT/feature/view-models

0 of 163 new or added lines in 33 files covered. (0.0%)

7 of 1062 relevant lines covered (0.66%)

0.03 hits per line

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

0.0
/Classes/Domain/ViewModel/Builder/SelectViewModelBuilder.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\ViewModel\Builder;
19

20
use CPSIT\Typo3HandlebarsForms\Domain;
21
use TYPO3\CMS\Fluid;
22
use TYPO3\CMS\Form;
23
use TYPO3Fluid\Fluid as FluidStandalone;
24

25
/**
26
 * SelectViewModelBuilder
27
 *
28
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
29
 * @license GPL-2.0-or-later
30
 *
31
 * @extends AbstractViewModelBuilder<Form\Domain\Model\FormElements\GenericFormElement>
32
 */
33
final class SelectViewModelBuilder extends AbstractViewModelBuilder
34
{
35
    protected array $supportedTypes = [
36
        'MultiSelect',
37
        'SingleSelect',
38
    ];
39

40
    public function renderRenderable(
×
41
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
42
        Fluid\Core\Rendering\RenderingContext $renderingContext,
43
    ): Domain\ViewModel\ViewHelperContainedViewModel {
44
        $result = $this->viewHelperInvoker->invoke(
×
45
            $renderingContext,
×
46
            Fluid\ViewHelpers\Form\SelectViewHelper::class,
×
47
            [
×
48
                'property' => $renderable->getIdentifier(),
×
49
                'id' => $renderable->getUniqueIdentifier(),
×
50
                'class' => $renderable->getProperties()['elementClassAttribute'] ?? null,
×
51
                'options' => $this->viewHelperInvoker->translateElementProperty($renderingContext, $renderable, 'options'),
×
52
                'multiple' => $renderable->getType() === 'MultiSelect' ? 'multiple' : null,
×
53
                'errorClass' => $renderable->getProperties()['elementErrorClassAttribute'] ?? null,
×
54
                'additionalAttributes' => $this->renderAdditionalAttributes($renderable, $renderingContext),
×
55
                'prependOptionLabel' => $this->viewHelperInvoker->translateElementProperty($renderingContext, $renderable, 'prependOptionLabel'),
×
56
                'prependOptionValue' => $this->viewHelperInvoker->translateElementProperty($renderingContext, $renderable, 'prependOptionValue'),
×
57
            ],
×
58
        );
×
59

NEW
60
        $children = array_map(
×
NEW
61
            static fn(FluidStandalone\Core\ViewHelper\TagBuilder $tag) => new Domain\ViewModel\StandaloneTagViewModel(
×
NEW
62
                $renderable,
×
NEW
63
                $tag,
×
NEW
64
            ),
×
NEW
65
            $result->extractChildNodes('option'),
×
NEW
66
        );
×
67

NEW
68
        return new Domain\ViewModel\ViewHelperContainedViewModel($renderable, $result, $children);
×
69
    }
70
}
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