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

FluidTYPO3 / vhs / 12968595783

25 Jan 2025 09:30PM UTC coverage: 72.268%. Remained the same
12968595783

Pull #1925

github

web-flow
Merge aa1eb976f into 0ca5a1c10
Pull Request #1925: [BUGFIX] Replace all evaluateCondition methods with verdict methods

19 of 27 new or added lines in 9 files covered. (70.37%)

25 existing lines in 4 files now uncovered.

5548 of 7677 relevant lines covered (72.27%)

13.46 hits per line

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

77.78
/Classes/ViewHelpers/Condition/Page/HasSubpagesViewHelper.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 TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
14
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
15

16
/**
17
 * ### Condition: Page has subpages
18
 *
19
 * A condition ViewHelper which renders the `then` child if
20
 * current page or page with provided UID has subpages. By default
21
 * disabled subpages are considered non existent which can be overridden
22
 * by setting $includeHidden to TRUE. To include pages that are hidden
23
 * in menus set $showHiddenInMenu to TRUE.
24
 */
25
class HasSubpagesViewHelper extends AbstractConditionViewHelper
26
{
27
    /**
28
     * @var PageService
29
     */
30
    protected static $pageService;
31

32
    public static function setPageService(PageService $pageService): void
33
    {
34
        static::$pageService = $pageService;
12✔
35
    }
36

37
    public function initializeArguments(): void
38
    {
39
        parent::initializeArguments();
6✔
40
        $this->registerArgument('pageUid', 'integer', 'Parent page to check');
6✔
41
        $this->registerArgument('includeHidden', 'boolean', 'DEPRECATED: Include hidden pages', false, false);
6✔
42
        $this->registerArgument('includeAccessProtected', 'boolean', 'Include access protected pages', false, false);
6✔
43
        $this->registerArgument('includeHiddenInMenu', 'boolean', 'Include pages hidden in menu', false, false);
6✔
44
    }
45

46
    public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool
47
    {
48
        if (!is_array($arguments)) {
12✔
49
            return false;
×
50
        }
51
        $pageUid = $arguments['pageUid'];
12✔
52
        $includeHiddenInMenu = (boolean) $arguments['includeHiddenInMenu'];
12✔
53
        $includeAccessProtected = (boolean) $arguments['includeAccessProtected'];
12✔
54

55
        if (empty($pageUid) || 0 === (integer) $pageUid) {
12✔
UNCOV
56
            $pageUid = $GLOBALS['TSFE']->id;
×
57
        }
58

59
        if (static::$pageService === null) {
12✔
60
            /** @var PageService $pageService */
UNCOV
61
            $pageService = GeneralUtility::makeInstance(PageService::class);
×
62
            static::$pageService = $pageService;
×
63
        }
64

65
        $menu = static::$pageService->getMenu($pageUid, [], $includeHiddenInMenu, false, $includeAccessProtected);
12✔
66

67
        return (0 < count($menu));
12✔
68
    }
69
}
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