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

CPS-IT / handlebars-forms / 24181295131

09 Apr 2026 08:46AM UTC coverage: 0.587% (-0.002%) from 0.589%
24181295131

push

github

eliashaeussler
[FEATURE] Include resource pointer field in `FileUpload` view model

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

32 existing lines in 2 files now uncovered.

7 of 1193 relevant lines covered (0.59%)

0.02 hits per line

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

0.0
/Classes/Fluid/ViewHelperInvocationResult.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\Fluid;
19

20
use TYPO3\CMS\Fluid;
21
use TYPO3Fluid\Fluid as FluidStandalone;
22

23
/**
24
 * ViewHelperInvocationResult
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 */
29
final readonly class ViewHelperInvocationResult
30
{
31
    public function __construct(
×
32
        public FluidStandalone\Core\ViewHelper\ViewHelperInterface $viewHelper,
33
        public Fluid\Core\Rendering\RenderingContext $renderingContext,
34
        public mixed $content,
35
        public FluidStandalone\Core\ViewHelper\TagBuilder $tag = new FluidStandalone\Core\ViewHelper\TagBuilder(),
36
    ) {}
×
37

38
    /**
39
     * @param non-empty-string $tagName
40
     * @return list<FluidStandalone\Core\ViewHelper\TagBuilder>
41
     */
42
    public function extractChildNodes(string $tagName): array
×
43
    {
44
        $content = $this->content ?? $this->tag->getContent();
×
45
        $children = [];
×
46

47
        // Early return if no suitable content is provided
48
        if (!is_scalar($content) || (string)$content === '') {
×
49
            return [];
×
50
        }
51

52
        // Enforce UTF-8 on the rendered tag content
53
        $useInternalErrors = libxml_use_internal_errors(true);
×
54
        $html = '<?xml encoding="UTF-8">' . $content;
×
55

56
        // Load tag content as DOMDocument
57
        try {
58
            $dom = new \DOMDocument();
×
59
            $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
×
60
        } finally {
61
            libxml_use_internal_errors($useInternalErrors);
×
62
        }
63

64
        // Parse nodes
65
        $xpath = new \DOMXPath($dom);
×
66
        $nodes = $xpath->query('//' . $tagName);
×
67

68
        // Early return if queried nodes are invalid
69
        if (!($nodes instanceof \DOMNodeList)) {
×
70
            return [];
×
71
        }
72

73
        // Convert nodes to view models
74
        foreach ($nodes as $node) {
×
75
            if (!($node instanceof \DOMElement)) {
×
76
                continue;
×
77
            }
78

NEW
79
            $tag = new FluidStandalone\Core\ViewHelper\TagBuilder($node->tagName, trim($node->textContent));
×
80

81
            /** @var \DOMAttr $attribute */
82
            foreach ($node->attributes as $attribute) {
×
83
                $tag->addAttribute($attribute->name, $attribute->value);
×
84
            }
85

86
            $children[] = $tag;
×
87
        }
88

89
        return $children;
×
90
    }
91
}
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