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

CPS-IT / handlebars / 22296182851

23 Feb 2026 07:05AM UTC coverage: 90.285% (+0.01%) from 90.272%
22296182851

Pull #535

github

web-flow
Merge d95b62f98 into 0156316ee
Pull Request #535: [TASK] Allow access to configured template name in `HandlebarsView`

2 of 2 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

1329 of 1472 relevant lines covered (90.29%)

6.92 hits per line

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

90.32
/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
            Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->contentObjectConfiguration['settings.'], $value);
1✔
56
        } else {
57
            $this->contentObjectConfiguration['variables.'][$key] = $value;
3✔
58
        }
59

60
        return $this;
4✔
61
    }
62

63
    /**
64
     * @param array<string, mixed> $values
65
     */
66
    public function assignMultiple(array $values): self
1✔
67
    {
68
        foreach ($values as $key => $value) {
1✔
69
            $this->assign($key, $value);
1✔
70
        }
71

72
        return $this;
1✔
73
    }
74

75
    public function render(string $templateFileName = ''): string
7✔
76
    {
77
        $contentObjectRenderer = $this->contentObjectRenderer;
7✔
78
        $contentObjectConfiguration = $this->contentObjectConfiguration;
7✔
79

80
        if ($templateFileName !== '') {
7✔
81
            $contentObjectConfiguration['templateName'] = $templateFileName;
×
82
        }
83

84
        if ($this->request !== null) {
7✔
85
            $contentObjectRenderer = clone $contentObjectRenderer;
1✔
86
            $contentObjectRenderer->setRequest($this->request);
1✔
87
        }
88

89
        return $contentObjectRenderer->cObjGetSingle('HANDLEBARSTEMPLATE', $contentObjectConfiguration);
7✔
90
    }
91

92
    public function setTemplateName(string $templateName): self
1✔
93
    {
94
        $this->contentObjectConfiguration['templateName'] = $templateName;
1✔
95

96
        return $this;
1✔
97
    }
98

99
    public function getTemplateName(): ?string
1✔
100
    {
101
        return $this->contentObjectConfiguration['templateName'] ?? null;
1✔
102
    }
103

UNCOV
104
    public function getRequest(): ?Message\ServerRequestInterface
×
105
    {
106
        return $this->request;
×
107
    }
108
}
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