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

CPS-IT / handlebars-forms / 23141119397

16 Mar 2026 11:20AM UTC coverage: 0.0%. Remained the same
23141119397

push

github

eliashaeussler
[TASK] Add view model builder for `StaticText`

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

0 of 742 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/StaticTextViewModelBuilder.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 TYPO3\CMS\Fluid;
21
use TYPO3\CMS\Form;
22
use TYPO3Fluid\Fluid as StandaloneFluid;
23

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

NEW
38
    public function renderRenderable(
×
39
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
40
        Fluid\Core\Rendering\RenderingContext $renderingContext,
41
    ): ViewModel {
NEW
42
        $label = $this->viewHelperInvoker->translateElementProperty($renderingContext, $renderable, 'label');
×
NEW
43
        $text = $this->viewHelperInvoker->translateElementProperty($renderingContext, $renderable, 'text');
×
NEW
44
        $className = $renderable->getProperties()['elementClassAttribute'] ?? null;
×
45

NEW
46
        if (is_string($text)) {
×
NEW
47
            $text = nl2br($text);
×
48
        }
49

NEW
50
        $tag = new StandaloneFluid\Core\ViewHelper\TagBuilder('p', $text);
×
51

NEW
52
        if (is_string($className)) {
×
NEW
53
            $tag->addAttribute('class', $className);
×
54
        }
55

NEW
56
        return new ViewModel($renderingContext, $label, $tag);
×
57
    }
58
}
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