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

CPS-IT / handlebars / 21710077503

05 Feb 2026 11:40AM UTC coverage: 90.083% (-0.1%) from 90.181%
21710077503

Pull #525

github

web-flow
Merge 693350b00 into ea0903656
Pull Request #525: [BUGFIX] Hand over request from view factory data to `HandlebarsView`

6 of 8 new or added lines in 2 files covered. (75.0%)

1299 of 1442 relevant lines covered (90.08%)

6.94 hits per line

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

88.46
/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(
6✔
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
    ) {}
6✔
43

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

52
        $this->contentObjectConfiguration['variables.'][$key] = $value;
3✔
53

54
        return $this;
3✔
55
    }
56

57
    /**
58
     * @param array<string, mixed> $values
59
     */
60
    public function assignMultiple(array $values): self
1✔
61
    {
62
        foreach ($values as $key => $value) {
1✔
63
            $this->assign($key, $value);
1✔
64
        }
65

66
        return $this;
1✔
67
    }
68

69
    public function render(string $templateFileName = ''): string
6✔
70
    {
71
        $contentObjectRenderer = $this->contentObjectRenderer;
6✔
72
        $contentObjectConfiguration = $this->contentObjectConfiguration;
6✔
73

74
        if ($templateFileName !== '') {
6✔
75
            $contentObjectConfiguration['templateName'] = $templateFileName;
×
76
        }
77

78
        if ($this->request !== null) {
6✔
79
            $contentObjectRenderer = clone $contentObjectRenderer;
1✔
80
            $contentObjectRenderer->setRequest($this->request);
1✔
81
        }
82

83
        return $contentObjectRenderer->cObjGetSingle('HANDLEBARSTEMPLATE', $contentObjectConfiguration);
6✔
84
    }
85

86
    public function setTemplateName(string $templateName): self
1✔
87
    {
88
        $this->contentObjectConfiguration['templateName'] = $templateName;
1✔
89

90
        return $this;
1✔
91
    }
92

NEW
93
    public function getRequest(): ?Message\ServerRequestInterface
×
94
    {
NEW
95
        return $this->request;
×
96
    }
97
}
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