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

FluidTYPO3 / vhs / 30001290505

23 Jul 2026 10:57AM UTC coverage: 70.309% (-1.7%) from 72.022%
30001290505

push

github

NamelessCoder
[TER] 8.0.0

4819 of 6854 relevant lines covered (70.31%)

6.54 hits per line

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

64.71
/Classes/ViewHelpers/Variable/ExtensionConfigurationViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Variable;
3

4
/*
5
 * This file is part of the FluidTYPO3/Vhs 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\Vhs\Core\ViewHelper\AbstractViewHelper;
12
use FluidTYPO3\Vhs\Utility\RequestResolver;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
15
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
16
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
17
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
18

19
/**
20
 * ### ExtConf ViewHelper
21
 *
22
 * Reads settings from ext_conf_template.txt
23
 *
24
 * ### Examples
25
 *
26
 * ```
27
 * {v:variable.extensionConfiguration(extensionKey:'foo',path:'bar.baz')}
28
 * ```
29
 *
30
 * Returns setting `bar.baz` from extension 'foo' located in `ext_conf_template.txt`.
31
 */
32
class ExtensionConfigurationViewHelper extends AbstractViewHelper
33
{
34
    /**
35
     * @var array
36
     */
37
    protected static $configurations = [];
38

39
    public function initializeArguments(): void
40
    {
41
        $this->registerArgument(
3✔
42
            'extensionKey',
3✔
43
            'string',
3✔
44
            'Extension key (lowercase_underscored format) to read configuration from'
3✔
45
        );
3✔
46
        $this->registerArgument(
3✔
47
            'path',
3✔
48
            'string',
3✔
49
            'Configuration path to read - if NULL, returns all configuration as array'
3✔
50
        );
3✔
51
    }
52

53
    /**
54
     * @return mixed
55
     */
56
    public static function renderStatic(
57
        array $arguments,
58
        \Closure $renderChildrenClosure,
59
        RenderingContextInterface $renderingContext
60
    ) {
61
        /** @var RenderingContext $renderingContext */
62
        /** @var string|null $extensionKey */
63
        $extensionKey = $arguments['extensionKey'];
18✔
64
        /** @var string $path */
65
        $path = $arguments['path'];
18✔
66

67
        if (null === $extensionKey) {
18✔
68
            $extensionName = RequestResolver::resolveControllerExtensionNameFromRenderingContext($renderingContext);
×
69
            if ($extensionName) {
×
70
                $extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName);
×
71
            }
72
        }
73

74
        if (!$extensionKey) {
18✔
75
            throw new Exception(
×
76
                'Could not resolve extension key from request. Please pass argument "extensionKey".',
×
77
                1721314563
×
78
            );
×
79
        }
80

81
        if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extensionKey]) &&
18✔
82
            !isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey])) {
18✔
83
            return null;
×
84
        } elseif (!array_key_exists($extensionKey, static::$configurations)) {
18✔
85
            if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extensionKey])) {
3✔
86
                $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extensionKey];
3✔
87
            } elseif (is_string($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey])) {
×
88
                $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
×
89
            } else {
90
                $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey];
×
91
            }
92
            static::$configurations[$extensionKey] = GeneralUtility::removeDotsFromTS($extConf);
3✔
93
        }
94

95
        if (!$path) {
18✔
96
            return static::$configurations[$extensionKey];
×
97
        }
98

99
        return ObjectAccess::getPropertyPath(static::$configurations[$extensionKey], $path);
18✔
100
    }
101
}
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