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

FluidTYPO3 / vhs / 28022997566

23 Jun 2026 11:30AM UTC coverage: 71.402% (+0.7%) from 70.695%
28022997566

push

github

NamelessCoder
[REMOVAL] Remove asset feature

Use any other method - for example, all supported versions of
TYPO3 contain the AssetCollector feature.

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

30 existing lines in 2 files now uncovered.

4926 of 6899 relevant lines covered (71.4%)

14.6 hits per line

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

0.0
/Classes/ViewHelpers/LViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers;
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\Utility\RequestResolver;
12
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
13
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15
use FluidTYPO3\Vhs\Core\ViewHelper\AbstractViewHelper;
16

17
/**
18
 * ### L (localisation) ViewHelper
19
 *
20
 * An extremely shortened and much more dev-friendly
21
 * alternative to f:translate. Automatically outputs
22
 * the name of the LLL reference if it is not found
23
 * and the default value is not set, making it much
24
 * easier to identify missing labels when translating.
25
 *
26
 * ### Examples
27
 *
28
 * ```
29
 * <v:l>some.label</v:l>
30
 * <v:l key="some.label" />
31
 * <v:l arguments="{0: 'foo', 1: 'bar'}">some.label</v:l>
32
 * ```
33
 */
34
class LViewHelper extends AbstractViewHelper
35
{
36
    /**
37
     * @var boolean
38
     */
39
    protected $escapeChildren = false;
40

41
    /**
42
     * @var boolean
43
     */
44
    protected $escapeOutput = false;
45

46
    public function initializeArguments(): void
47
    {
UNCOV
48
        $this->registerArgument('key', 'string', 'Translation Key');
×
UNCOV
49
        $this->registerArgument(
×
UNCOV
50
            'default',
×
UNCOV
51
            'string',
×
UNCOV
52
            'if the given locallang key could not be found, this value is used. If this argument is not set, ' .
×
UNCOV
53
            'child nodes will be used to render the default'
×
UNCOV
54
        );
×
UNCOV
55
        $this->registerArgument(
×
UNCOV
56
            'htmlEscape',
×
UNCOV
57
            'boolean',
×
UNCOV
58
            'TRUE if the result should be htmlescaped. This won\'t have an effect for the default value'
×
UNCOV
59
        );
×
UNCOV
60
        $this->registerArgument('arguments', 'array', 'Arguments to be replaced in the resulting string');
×
UNCOV
61
        $this->registerArgument('extensionName', 'string', 'UpperCamelCased extension key (for example BlogExample)');
×
62
    }
63

64
    /**
65
     * @return mixed
66
     */
67
    public static function renderStatic(
68
        array $arguments,
69
        \Closure $renderChildrenClosure,
70
        RenderingContextInterface $renderingContext
71
    ) {
72
        /** @var RenderingContext $renderingContext */
73
        /** @var string|null $default */
UNCOV
74
        $default = $arguments['default'];
×
UNCOV
75
        $htmlEscape = (bool) $arguments['htmlEscape'];
×
76
        /** @var string|null $extensionName */
UNCOV
77
        $extensionName = $arguments['extensionName'];
×
78
        /** @var array|null $translationArguments */
UNCOV
79
        $translationArguments = $arguments['arguments'];
×
80
        /** @var string $id */
UNCOV
81
        $id = $arguments['key'] ?? $renderChildrenClosure();
×
UNCOV
82
        if (empty($default)) {
×
UNCOV
83
            $default = $id;
×
84
        }
UNCOV
85
        if (empty($extensionName)) {
×
86
            $extensionName = RequestResolver::resolveControllerExtensionNameFromRenderingContext($renderingContext);
×
87
        }
88
        /** @var string|null $value */
UNCOV
89
        $value = LocalizationUtility::translate((string) $id, $extensionName, $translationArguments);
×
UNCOV
90
        if (empty($value)) {
×
UNCOV
91
            $value = $default;
×
UNCOV
92
            if (!empty($translationArguments)) {
×
UNCOV
93
                $value = vsprintf($value, $translationArguments);
×
94
            }
95
        } elseif ($htmlEscape) {
×
96
            $value = htmlspecialchars((string) $value);
×
97
        }
UNCOV
98
        return $value;
×
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