• 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

83.33
/Classes/ViewHelpers/Condition/Page/IsChildPageViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Condition\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\Service\PageService;
12
use FluidTYPO3\Vhs\Utility\RequestResolver;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
16

17
/**
18
 * ### Condition: Page is child page
19
 *
20
 * Condition ViewHelper which renders the `then` child if current
21
 * page or page with provided UID is a child of some other page in
22
 * the page tree. If $respectSiteRoot is set to TRUE root pages are
23
 * never considered child pages even if they are.
24
 */
25
class IsChildPageViewHelper extends AbstractConditionViewHelper
26
{
27
    public function initializeArguments(): void
28
    {
29
        parent::initializeArguments();
3✔
30
        $this->registerArgument('pageUid', 'integer', 'value to check');
3✔
31
        $this->registerArgument('respectSiteRoot', 'boolean', 'value to check', false, false);
3✔
32
    }
33

34
    public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
35
    {
36
        /** @var int $pageUid */
37
        $pageUid = $arguments['pageUid'];
3✔
38
        $respectSiteRoot = (bool) $arguments['respectSiteRoot'];
3✔
39

40
        if (empty($pageUid)) {
3✔
41
            /** @var int $pageUid */
42
            $pageUid = RequestResolver::getPageUid();
×
43
        }
44
        /** @var PageService $pageService */
45
        $pageService = GeneralUtility::makeInstance(PageService::class);
3✔
46
        $page = $pageService->getPageRepository()->getPage($pageUid);
3✔
47

48
        if ($respectSiteRoot && ($page['is_siteroot'] ?? false)) {
3✔
49
            return false;
3✔
50
        }
51
        return ($page['pid'] ?? 0) > 0;
×
52
    }
53
}
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