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

FluidTYPO3 / vhs / 28371118611

29 Jun 2026 12:11PM UTC coverage: 69.786%. Remained the same
28371118611

push

github

NamelessCoder
[TASK] Get rid of LF constant usage

9 of 15 new or added lines in 10 files covered. (60.0%)

4795 of 6871 relevant lines covered (69.79%)

4.03 hits per line

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

61.54
/Classes/ViewHelpers/Content/Random/RenderViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Content\Random;
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\Traits\ArgumentOverride;
12
use FluidTYPO3\Vhs\Utility\ContextUtility;
13
use FluidTYPO3\Vhs\ViewHelpers\Content\AbstractContentViewHelper;
14

15
/**
16
 * ViewHelper for rendering a random content element in Fluid page templates.
17
 */
18
class RenderViewHelper extends AbstractContentViewHelper
19
{
20
    use ArgumentOverride;
21

22
    public function initializeArguments(): void
23
    {
24
        parent::initializeArguments();
4✔
25
        $this->overrideArgument('limit', 'integer', 'Optional limit number of content elements to render', false, 1);
4✔
26
    }
27

28
    public function render(): string|array
29
    {
30
        if (ContextUtility::isBackend()) {
4✔
31
            return '';
×
32
        }
33
        // Remove limit for getContentRecords()
34
        /** @var int $limit */
35
        $limit = $this->arguments['limit'];
4✔
36
        $this->arguments['limit'] = null;
4✔
37
        // Just using getContentRecords with a limit of 1 would not support
38
        // using slideCollect as collecting would stop as soon as one record
39
        // was found. As a potential optimization, $render could be overrided
40
        // so all the content records that end up unused do not get rendered.
41
        $contentRecords = $this->getContentRecords();
4✔
42
        if (!empty($contentRecords)) {
4✔
43
            shuffle($contentRecords);
×
44
            $contentRecords = array_slice($contentRecords, 0, $limit);
×
45
            if ($this->arguments['render']) {
×
NEW
46
                $contentRecords = implode(PHP_EOL, $contentRecords);
×
47
            }
48
        }
49
        return $contentRecords;
4✔
50
    }
51
}
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