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

CPS-IT / handlebars / 32943176293

26 Aug 2026 07:31AM UTC coverage: 89.571% (-0.2%) from 89.802%
32943176293

Pull #622

github

web-flow
Merge 604f55cc8 into 2f9b421f6
Pull Request #622: [FEATURE] Let variable providers control their cache behavior

9 of 14 new or added lines in 3 files covered. (64.29%)

1546 of 1726 relevant lines covered (89.57%)

6.89 hits per line

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

81.48
/Classes/Renderer/Variables/TypoScriptVariableProvider.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\Renderer\Variables;
19

20
use CPSIT\Typo3Handlebars\Extension;
21
use TYPO3\CMS\Extbase;
22

23
/**
24
 * TypoScriptVariableProvider
25
 *
26
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
27
 * @license GPL-2.0-or-later
28
 */
29
final class TypoScriptVariableProvider implements VariableProvider
30
{
31
    /**
32
     * @var array<string|int, mixed>|null
33
     */
34
    private ?array $variables = null;
35

36
    public function __construct(
5 ✔
37
        private readonly Extbase\Configuration\ConfigurationManagerInterface $configurationManager,
38
    ) {}
5 ✔
39

40
    public function get(): array
3 ✔
41
    {
42
        if ($this->variables === null) {
3 ✔
43
            $this->variables = $this->fetchVariables();
3 ✔
44
        }
45

46
        return $this->variables;
3 ✔
47
    }
48

NEW
49
    public function isCacheable(): bool
×
50
    {
NEW
51
        return true;
×
52
    }
53

54
    public function offsetExists(mixed $offset): bool
1 ✔
55
    {
56
        return isset($this->get()[$offset]);
1 ✔
57
    }
58

59
    public function offsetGet(mixed $offset): mixed
1 ✔
60
    {
61
        return $this->get()[$offset] ?? null;
1 ✔
62
    }
63

64
    public function offsetSet(mixed $offset, mixed $value): never
1 ✔
65
    {
66
        throw new \LogicException('Variables cannot be modified.', 1736274326);
1 ✔
67
    }
68

69
    public function offsetUnset(mixed $offset): never
1 ✔
70
    {
71
        throw new \LogicException('Variables cannot be modified.', 1736274336);
1 ✔
72
    }
73

74
    public static function getPriority(): int
×
75
    {
76
        return 50;
×
77
    }
78

79
    /**
80
     * @return array<string|int, mixed>
81
     */
82
    private function fetchVariables(): array
3 ✔
83
    {
84
        $typoScriptConfiguration = $this->configurationManager->getConfiguration(
3 ✔
85
            Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
3 ✔
86
            Extension::NAME,
3 ✔
87
        );
3 ✔
88
        $variables = $typoScriptConfiguration['variables'] ?? [];
3 ✔
89

90
        if (!is_array($variables)) {
3 ✔
91
            return [];
×
92
        }
93

94
        return $variables;
3 ✔
95
    }
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc