• 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

43.48
/Classes/ViewHelpers/Page/BreadCrumbViewHelper.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\Traits\ArgumentOverride;
12
use FluidTYPO3\Vhs\ViewHelpers\Menu\AbstractMenuViewHelper;
13
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
14

15
/**
16
 * ViewHelper to make a breadcrumb link set from a pageUid, automatic or manual.
17
 */
18
class BreadCrumbViewHelper extends AbstractMenuViewHelper
19
{
20
    use ArgumentOverride;
21

22
    public function initializeArguments(): void
23
    {
24
        parent::initializeArguments();
7✔
25
        $this->registerArgument(
7✔
26
            'pageUid',
7✔
27
            'integer',
7✔
28
            'Optional parent page UID to use as top level of menu. If left out will be detected from ' .
7✔
29
            'rootLine using $entryLevel.'
7✔
30
        );
7✔
31
        $this->registerArgument(
7✔
32
            'endLevel',
7✔
33
            'integer',
7✔
34
            'Optional deepest level of rendering. If left out all levels up to the current are rendered.'
7✔
35
        );
7✔
36
        $this->overrideArgument(
7✔
37
            'as',
7✔
38
            'string',
7✔
39
            'If used, stores the menu pages as an array in a variable named after this value and renders the tag ' .
7✔
40
            'content. If the tag content is empty automatic rendering is triggered.',
7✔
41
            false,
7✔
42
            'breadcrumb'
7✔
43
        );
7✔
44
    }
45

46
    /**
47
     * @return string
48
     */
49
    public function render()
50
    {
51
        $pageUid = $this->arguments['pageUid'] > 0 ? $this->arguments['pageUid'] : $GLOBALS['TSFE']->id;
×
52
        /** @var int $entryLevel */
53
        $entryLevel = $this->arguments['entryLevel'];
×
54
        /** @var int|null $endLevel */
55
        $endLevel = $this->arguments['endLevel'];
×
56
        $rawRootLineData = $this->pageService->getRootLine($pageUid);
×
57
        $rawRootLineData = array_reverse($rawRootLineData);
×
58
        $rawRootLineData = array_slice($rawRootLineData, $entryLevel, $endLevel);
×
59
        $rootLineData = [];
×
60
        $showHidden = (boolean) $this->arguments['showHiddenInMenu'];
×
61
        $spacerDoktype = PageRepository::DOKTYPE_SPACER;
×
62
        foreach ($rawRootLineData as $record) {
×
63
            $isHidden = (boolean) $record['nav_hide'];
×
64

65
            if ($this->arguments['includeSpacers']) {
×
66
                $isAllowedDoktype = (int) $record['doktype'] <= $spacerDoktype;
×
67
            } else {
68
                $isAllowedDoktype = (int) $record['doktype'] < $spacerDoktype;
×
69
            }
70

71
            if (($showHidden && $isHidden || !$isHidden) && $isAllowedDoktype) {
×
72
                $rootLineData[] = $record;
×
73
            }
74
        }
75
        $rootLine = $this->parseMenu($rootLineData);
×
76
        if (0 === count($rootLine)) {
×
77
            return '';
×
78
        }
79
        $this->backupVariables();
×
80
        /** @var string $as */
81
        $as = $this->arguments['as'];
×
82
        $this->renderingContext->getVariableProvider()->add($as, $rootLine);
×
83
        $output = $this->renderContent($rootLine);
×
84
        $this->renderingContext->getVariableProvider()->remove($as);
×
85
        $this->restoreVariables();
×
86

87
        return $output;
×
88
    }
89
}
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