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

FluidTYPO3 / vhs / 28588802516

02 Jul 2026 12:08PM UTC coverage: 70.321% (+0.4%) from 69.971%
28588802516

push

github

NamelessCoder
[TASK] Remove most of the remaining TSFE usages

21 of 32 new or added lines in 7 files covered. (65.63%)

4836 of 6877 relevant lines covered (70.32%)

4.41 hits per line

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

69.7
/Classes/ViewHelpers/Media/AbstractMediaViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Media;
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\TagViewHelperCompatibility;
12
use FluidTYPO3\Vhs\Utility\ContextUtility;
13
use FluidTYPO3\Vhs\Utility\ParameterUtility;
14
use FluidTYPO3\Vhs\Utility\RequestResolver;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Core\Utility\PathUtility;
17
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
18

19
/**
20
 * Base class for media related view helpers.
21
 */
22
abstract class AbstractMediaViewHelper extends AbstractTagBasedViewHelper
23
{
24
    use TagViewHelperCompatibility;
25

26
    protected string $mediaSource = '';
27

28
    public function initializeArguments(): void
29
    {
30
        parent::initializeArguments();
12✔
31
        $this->registerArgument(
12✔
32
            'src',
12✔
33
            'mixed',
12✔
34
            'Path to the media resource(s). Can contain single or multiple paths for videos/audio (either CSV, ' .
12✔
35
            'array or implementing Traversable).',
12✔
36
            true
12✔
37
        );
12✔
38
        $this->registerArgument(
12✔
39
            'relative',
12✔
40
            'boolean',
12✔
41
            'If FALSE media URIs are rendered absolute. URIs in backend mode are always absolute.',
12✔
42
            false,
12✔
43
            true
12✔
44
        );
12✔
45
    }
46

47
    /**
48
     * Turns a relative source URI into an absolute URL
49
     * if required.
50
     */
51
    public static function preprocessSourceUri(string $src, array $arguments): string
52
    {
53
        $src = str_replace('%2F', '/', rawurlencode($src));
2✔
54
        if (substr($src, 0, 1) !== '/' && substr($src, 0, 4) !== 'http') {
2✔
55
            $src = RequestResolver::getFrontendUrlPrefix() . $src;
2✔
56
        }
57
        $staticPrefix = RequestResolver::getStaticPrefix();
2✔
58
        if ($staticPrefix !== '') {
2✔
NEW
59
            $src = $staticPrefix . $src;
×
60
        } elseif (ContextUtility::isBackend() || !$arguments['relative']) {
2✔
61
            /** @var string $siteUrl */
NEW
62
            $siteUrl = ParameterUtility::resolveParameterValue('TYPO3_SITE_URL');
×
63
            $src = $siteUrl . ltrim($src, '/');
×
64
        }
65
        if (empty($src)) {
2✔
66
            // Do not pass an empty $src to PathUtility, it requires non-empty strings on 10.4.
67
            return '';
2✔
68
        }
69
        return PathUtility::getAbsoluteWebPath($src);
×
70
    }
71

72
    /**
73
     * Returns an array of sources resolved from src argument
74
     * which can be either an array, CSV or implement Traversable
75
     * to be consumed by ViewHelpers handling multiple sources.
76
     */
77
    public static function getSourcesFromArgument(array $arguments): array
78
    {
79
        $src = $arguments['src'];
×
80
        if ($src instanceof \Traversable) {
×
81
            $src = iterator_to_array($src);
×
82
        } elseif (is_string($src)) {
×
83
            $src = GeneralUtility::trimExplode(',', $src, true);
×
84
        }
85
        return $src;
×
86
    }
87
}
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