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

eliashaeussler / typo3-solver / 19476272024

18 Nov 2025 06:03PM UTC coverage: 88.195% (+0.02%) from 88.172%
19476272024

push

github

web-flow
Merge pull request #497 from eliashaeussler/task/codeclimate

[TASK] Drop CodeClimate integration

904 of 1025 relevant lines covered (88.2%)

2.32 hits per line

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

93.75
/Classes/View/TemplateRenderer.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "solver".
7
 *
8
 * Copyright (C) 2023-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3Solver\View;
25

26
use TYPO3Fluid\Fluid;
27

28
/**
29
 * TemplateRenderer
30
 *
31
 * @author Elias Häußler <elias@haeussler.dev>
32
 * @license GPL-2.0-or-later
33
 * @internal
34
 */
35
final readonly class TemplateRenderer
36
{
37
    private Fluid\Core\Rendering\RenderingContextInterface $renderingContext;
38

39
    public function __construct()
1✔
40
    {
41
        $this->renderingContext = $this->createRenderingContext();
1✔
42
    }
43

44
    /**
45
     * @param array<string, mixed> $variables
46
     */
47
    public function render(string $templatePath, array $variables = []): string
1✔
48
    {
49
        $view = new Fluid\View\TemplateView($this->renderingContext);
1✔
50
        $view->assignMultiple($variables);
1✔
51
        $templateResult = $view->render($templatePath);
1✔
52

53
        if (!is_string($templateResult)) {
1✔
54
            return '';
×
55
        }
56

57
        return $templateResult;
1✔
58
    }
59

60
    private function createRenderingContext(): Fluid\Core\Rendering\RenderingContextInterface
1✔
61
    {
62
        $rootPath = \dirname(__DIR__, 2) . '/Resources/Private';
1✔
63
        $renderingContext = new Fluid\Core\Rendering\RenderingContext();
1✔
64

65
        $templatePaths = $renderingContext->getTemplatePaths();
1✔
66
        $templatePaths->setTemplateRootPaths([$rootPath . '/Templates']);
1✔
67
        $templatePaths->setPartialRootPaths([$rootPath . '/Partials']);
1✔
68

69
        return $renderingContext;
1✔
70
    }
71
}
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