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

CPS-IT / handlebars / 23361170525

20 Mar 2026 08:24PM UTC coverage: 90.027% (-0.3%) from 90.285%
23361170525

Pull #543

github

web-flow
Merge da28b186c into 86597a598
Pull Request #543: [TASK] Update codebase to match PHPStan level 9

127 of 142 new or added lines in 41 files covered. (89.44%)

7 existing lines in 4 files now uncovered.

1354 of 1504 relevant lines covered (90.03%)

6.84 hits per line

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

89.19
/Classes/View/HandlebarsView.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
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\Typo3Handlebars\View;
19

20
use Psr\Http\Message;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Core;
23
use TYPO3\CMS\Frontend;
24

25
/**
26
 * HandlebarsView
27
 *
28
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
29
 * @license GPL-2.0-or-later
30
 */
31
#[DependencyInjection\Attribute\Exclude]
32
final class HandlebarsView implements Core\View\ViewInterface
33
{
34
    /**
35
     * @param array<string, mixed> $contentObjectConfiguration
36
     */
37
    public function __construct(
8✔
38
        private readonly Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer,
39
        private readonly Core\TypoScript\TypoScriptService $typoScriptService,
40
        private array $contentObjectConfiguration,
41
        private readonly ?Message\ServerRequestInterface $request = null,
42
    ) {}
8✔
43

44
    public function assign(string $key, mixed $value): self
4✔
45
    {
46
        // Maintain TypoScript object structure
47
        if (is_array($value)) {
4✔
48
            $key .= '.';
2✔
49
            $value = $this->typoScriptService->convertPlainArrayToTypoScriptArray($value);
2✔
50
        }
51

52
        if ($key === 'settings.') {
4✔
53
            $this->contentObjectConfiguration['settings.'] ??= [];
1✔
54

55
            if (is_array($this->contentObjectConfiguration['settings.']) && is_array($value)) {
1✔
56
                Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->contentObjectConfiguration['settings.'], $value);
1✔
57
            }
58
        } else {
59
            $this->contentObjectConfiguration['variables.'] ??= [];
3✔
60

61
            if (is_array($this->contentObjectConfiguration['variables.'])) {
3✔
62
                $this->contentObjectConfiguration['variables.'][$key] = $value;
3✔
63
            }
64
        }
65

66
        return $this;
4✔
67
    }
68

69
    /**
70
     * @param array<string, mixed> $values
71
     */
72
    public function assignMultiple(array $values): self
1✔
73
    {
74
        foreach ($values as $key => $value) {
1✔
75
            $this->assign($key, $value);
1✔
76
        }
77

78
        return $this;
1✔
79
    }
80

81
    public function render(string $templateFileName = ''): string
7✔
82
    {
83
        $contentObjectRenderer = $this->contentObjectRenderer;
7✔
84
        $contentObjectConfiguration = $this->contentObjectConfiguration;
7✔
85

86
        if ($templateFileName !== '') {
7✔
87
            $contentObjectConfiguration['templateName'] = $templateFileName;
×
88
        }
89

90
        if ($this->request !== null) {
7✔
91
            $contentObjectRenderer = clone $contentObjectRenderer;
1✔
92
            $contentObjectRenderer->setRequest($this->request);
1✔
93
        }
94

95
        return $contentObjectRenderer->cObjGetSingle('HANDLEBARSTEMPLATE', $contentObjectConfiguration);
7✔
96
    }
97

98
    public function setTemplateName(string $templateName): self
1✔
99
    {
100
        $this->contentObjectConfiguration['templateName'] = $templateName;
1✔
101

102
        return $this;
1✔
103
    }
104

105
    public function getTemplateName(): ?string
1✔
106
    {
107
        $templateName = $this->contentObjectConfiguration['templateName'] ?? null;
1✔
108

109
        if (!is_string($templateName)) {
1✔
NEW
110
            return null;
×
111
        }
112

113
        return $templateName;
1✔
114
    }
115

116
    public function getRequest(): ?Message\ServerRequestInterface
×
117
    {
118
        return $this->request;
×
119
    }
120
}
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