• 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

85.71
/Classes/ViewHelpers/Variable/Register/SetViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Variable\Register;
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 TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
13
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
14

15
/**
16
 * ### Variable\Register: Set
17
 *
18
 * Sets a single register in the TSFE-register.
19
 *
20
 * Using as `{value -> v:variable.register.set(name: 'myVar')}` makes $GLOBALS["TSFE"]->register['myVar']
21
 * contain `{value}`.
22
 */
23
class SetViewHelper extends AbstractViewHelper
24
{
25
    /**
26
     * @var boolean
27
     */
28
    protected $escapeChildren = false;
29

30
    public function initializeArguments(): void
31
    {
32
        $this->registerArgument('value', 'mixed', 'Value to set');
3✔
33
        $this->registerArgument('name', 'string', 'Name of register', true);
3✔
34
    }
35

36
    /**
37
     * @return mixed
38
     */
39
    public static function renderStatic(
40
        array $arguments,
41
        \Closure $renderChildrenClosure,
42
        RenderingContextInterface $renderingContext
43
    ) {
44
        /** @var mixed $value */
45
        $value = $arguments['value'] ?? $renderChildrenClosure();
3✔
46
        if (!$GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
3✔
47
            return null;
×
48
        }
49
        $GLOBALS['TSFE']->register[$arguments['name']] = $value;
3✔
50
        return null;
3✔
51
    }
52
}
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