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

FluidTYPO3 / flux / 27757675993

18 Jun 2026 11:55AM UTC coverage: 89.162% (-3.5%) from 92.646%
27757675993

push

github

NamelessCoder
[TASK] Address last phpstan warnings

6228 of 6985 relevant lines covered (89.16%)

40.84 hits per line

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

96.3
/Classes/Service/TypoScriptService.php
1
<?php
2
namespace FluidTYPO3\Flux\Service;
3

4
/*
5
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use FluidTYPO3\Flux\Utility\ExtensionNamingUtility;
12
use TYPO3\CMS\Core\SingletonInterface;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
15
use TYPO3\CMS\Extbase\Configuration\Exception\NoServerRequestGivenException;
16

17
class TypoScriptService implements SingletonInterface
18
{
19
    private CacheService $cacheService;
20

21
    public function __construct(CacheService $cacheService)
22
    {
23
        $this->cacheService = $cacheService;
16✔
24
    }
25

26
    /**
27
     * Returns the plugin.tx_extsignature.settings array.
28
     * Accepts any input extension name type.
29
     */
30
    public function getSettingsForExtensionName(string $extensionName): array
31
    {
32
        $signature = ExtensionNamingUtility::getExtensionSignature($extensionName);
4✔
33
        return (array) $this->getTypoScriptByPath('plugin.tx_' . $signature . '.settings');
4✔
34
    }
35

36
    /**
37
     * Gets the value/array from global TypoScript by
38
     * dotted path expression.
39
     *
40
     * @return array|mixed
41
     */
42
    public function getTypoScriptByPath(string $path)
43
    {
44
        $cacheId = md5('ts_' . $path);
16✔
45
        $fromCache = $this->cacheService->getFromCaches($cacheId);
16✔
46
        if ($fromCache) {
16✔
47
            return $fromCache;
4✔
48
        }
49

50
        try {
51
            $all = $this->getConfigurationManager()->getConfiguration(
12✔
52
                ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
12✔
53
            );
12✔
54
        } catch (NoServerRequestGivenException $error) {
8✔
55
            // This case may happen when trying to read TypoScript from a CLI context. In this case, rather than just
56
            // giving up, we return an empty set of TypoScript.
57
            $all = [];
×
58
        } catch (\RuntimeException $exception) {
8✔
59
            if ($exception->getCode() !== 1700841298) {
8✔
60
                throw $exception;
4✔
61
            }
62
            // This will happen only on v13 and only when Flux is being triggered in uncached contexts (basically,
63
            // INT cObject types). The reason is that TS is not available in such contexts through ServerRequest.
64
            // This imposes a set of limitations on Flux in such contexts:
65
            // - Any and all TypoScript settings will not be available.
66
            // - This includes view path configurations - only default paths and/or paths specified by the Provider
67
            //   will be available when Flux tries to render things.
68
            // This affects several features of Flux, such as the ability to override Form details through TypoScript.
69
            // The affected features *ARE* relatively rarely used, but there's no reasonable way around it. The only
70
            // way that this *could* have been patched would be to reproduce all of the code from
71
            // TYPO3\CMS\Frontend\Middleware\PrepareTypoScriptFrontendRendering, which involves from-scratch attempting
72
            // to read, compile and finally parse every single TypoScript template throughout the root line.
73
            // A decision has been made that this is so excessive it will not be attempted. So, sorry, but if your use
74
            // case demands that you MUST have TypoScript available in your Flux context in uncached contexts on v13+,
75
            // your only option will be to replace this class and override this method, filling it with your preferred
76
            // way of reading TypoScript when it cannot be read from the ServerRequest "frontend.typoscript" attribute.
77
            $all = [];
4✔
78
        }
79

80
        $value = &$all;
8✔
81
        foreach (explode('.', $path) as $segment) {
8✔
82
            $value = ($value[$segment . '.'] ?? $value[$segment] ?? null);
8✔
83
            if ($value === null) {
8✔
84
                break;
4✔
85
            }
86
        }
87
        if (is_array($value)) {
8✔
88
            $value = GeneralUtility::removeDotsFromTS($value);
4✔
89
        }
90
        $this->cacheService->setInCaches($value, true, $cacheId);
8✔
91
        return $value;
8✔
92
    }
93

94
    protected function getConfigurationManager(): ConfigurationManagerInterface
95
    {
96
        /** @var ConfigurationManagerInterface $configurationManager */
97
        $configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
12✔
98
        return $configurationManager;
12✔
99
    }
100
}
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