• 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

93.75
/Classes/ViewHelpers/Page/InfoViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Page;
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 FluidTYPO3\Vhs\Service\PageService;
13
use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
14
use TYPO3\CMS\Core\Utility\GeneralUtility;
15
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
16

17
/**
18
 * ViewHelper to access data of the current page record.
19
 *
20
 * Does not work in the TYPO3 backend.
21
 */
22
class InfoViewHelper extends AbstractViewHelper
23
{
24
    use TemplateVariableViewHelperTrait;
25

26
    /**
27
     * @var boolean
28
     */
29
    protected $escapeOutput = false;
30

31
    public function initializeArguments(): void
32
    {
33
        $this->registerAsArgument();
3✔
34
        $this->registerArgument(
3✔
35
            'pageUid',
3✔
36
            'integer',
3✔
37
            'If specified, this UID will be used to fetch page data instead of using the current page.',
3✔
38
            false,
3✔
39
            0
3✔
40
        );
3✔
41
        $this->registerArgument(
3✔
42
            'field',
3✔
43
            'string',
3✔
44
            'If specified, only this field will be returned/assigned instead of the complete page record.'
3✔
45
        );
3✔
46
    }
47

48
    /**
49
     * @return mixed
50
     */
51
    public static function renderStatic(
52
        array $arguments,
53
        \Closure $renderChildrenClosure,
54
        RenderingContextInterface $renderingContext
55
    ) {
56
        /** @var PageService $pageService */
57
        $pageService = GeneralUtility::makeInstance(PageService::class);
3✔
58
        $pageRepository = $pageService->getPageRepository();
3✔
59
        /** @var int $pageUid */
60
        $pageUid = $arguments['pageUid'];
3✔
61
        if (0 === $pageUid) {
3✔
62
            $pageUid = $GLOBALS['TSFE']->id;
×
63
        }
64
        $page = $pageRepository->getPage_noCheck((int) $pageUid);
3✔
65
        /** @var string|null $field */
66
        $field = $arguments['field'];
3✔
67
        $content = null;
3✔
68
        if (empty($field)) {
3✔
69
            $content = $page;
×
70
        } elseif (is_array($page) && isset($page[$field])) {
3✔
71
            $content = $page[$field];
3✔
72
        }
73

74
        /** @var string|null $as */
75
        $as = $arguments['as'];
3✔
76
        return static::renderChildrenWithVariableOrReturnInputStatic(
3✔
77
            $content,
3✔
78
            $as,
3✔
79
            $renderingContext,
3✔
80
            $renderChildrenClosure
3✔
81
        );
3✔
82
    }
83
}
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