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

CPS-IT / handlebars-forms / 24127918937

08 Apr 2026 09:20AM UTC coverage: 0.589% (-0.002%) from 0.591%
24127918937

push

github

web-flow
Merge pull request #25 from CPS-IT/fix/file-upload

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

7 of 1188 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/Domain/ViewModel/Builder/FileUploadViewModelBuilder.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\Extbase;
22
use TYPO3\CMS\Fluid;
23
use TYPO3\CMS\Form;
24

25
/**
26
 * FileUploadViewModelBuilder
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\FileUpload>
32
 */
33
final class FileUploadViewModelBuilder extends AbstractViewModelBuilder
34
{
35
    protected array $supportedTypes = [
36
        'FileUpload',
37
    ];
38

39
    public function renderRenderable(
×
40
        Form\Domain\Model\Renderable\RootRenderableInterface $renderable,
41
        Fluid\Core\Rendering\RenderingContext $renderingContext,
42
    ): Domain\ViewModel\ViewModelCollection|Domain\ViewModel\ViewHelperContainedViewModel {
NEW
43
        $resource = null;
×
44
        $resourceVariableName = 'resource';
×
45
        $result = $this->viewHelperInvoker->invoke(
×
46
            $renderingContext,
×
47
            Form\ViewHelpers\Form\UploadedResourceViewHelper::class,
×
48
            [
×
49
                'property' => $renderable->getIdentifier(),
×
50
                'as' => $resourceVariableName,
×
51
                'id' => $renderable->getUniqueIdentifier(),
×
52
                'class' => $renderable->getProperties()['elementClassAttribute'] ?? null,
×
53
                'errorClass' => $renderable->getProperties()['elementErrorClassAttribute'] ?? null,
×
54
                'additionalAttributes' => $this->renderAdditionalAttributes($renderable, $renderingContext),
×
55
                'accept' => $renderable->getProperties()['allowedMimeTypes'] ?? null,
×
56
            ],
×
NEW
57
            static function () use ($renderingContext, &$resource, $resourceVariableName) {
×
NEW
58
                $resource = $renderingContext->getVariableProvider()->get($resourceVariableName);
×
NEW
59
            },
×
60
        );
×
61
        $inputViewModel = new Domain\ViewModel\ViewHelperContainedViewModel($renderable, $result);
×
62

63
        if ($resource instanceof Extbase\Domain\Model\FileReference) {
×
64
            return new Domain\ViewModel\ViewModelCollection(
×
65
                $renderable,
×
66
                [
×
67
                    $inputViewModel,
×
68
                    new Domain\ViewModel\FileResourceViewModel($renderable, $resource),
×
69
                ],
×
70
            );
×
71
        }
72

73
        return $inputViewModel;
×
74
    }
75
}
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