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

FluidTYPO3 / vhs / 13566190336

27 Feb 2025 12:18PM UTC coverage: 72.127% (-0.6%) from 72.746%
13566190336

push

github

NamelessCoder
[TER] 7.1.0

5649 of 7832 relevant lines covered (72.13%)

20.01 hits per line

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

25.0
/Classes/ViewHelpers/Media/ExistsViewHelper.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\Utility\CoreUtility;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
14
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
15

16
/**
17
 * File/Directory Exists Condition ViewHelper.
18
 */
19
class ExistsViewHelper extends AbstractConditionViewHelper
20
{
21
    public function initializeArguments(): void
22
    {
23
        parent::initializeArguments();
7✔
24
        $this->registerArgument('file', 'string', 'Filename which must exist to trigger f:then rendering');
7✔
25
        $this->registerArgument('directory', 'string', 'Directory which must exist to trigger f:then rendering');
7✔
26
    }
27

28
    public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
29
    {
30
        /** @var string $file */
31
        $file = $arguments['file'];
×
32
        $file = GeneralUtility::getFileAbsFileName((string) $file);
×
33
        /** @var string $directory */
34
        $directory = $arguments['directory'];
×
35
        $evaluation = false;
×
36
        if (isset($arguments['file'])) {
×
37
            $evaluation = ((file_exists($file) || file_exists(CoreUtility::getSitePath() . $file)) && is_file($file));
×
38
        } elseif (isset($arguments['directory'])) {
×
39
            $evaluation = (is_dir($directory) || is_dir(CoreUtility::getSitePath() . $directory));
×
40
        }
41
        return $evaluation;
×
42
    }
43
}
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