Total Complexity | 7 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
9 | class Breadcrumbs |
||
10 | { |
||
11 | public static function getFor(string $flatreference) |
||
12 | { |
||
13 | return app(SiteStructure::class)->getForReference($flatreference); |
||
14 | } |
||
15 | |||
16 | public static function getForPage(Page $page) |
||
17 | { |
||
18 | return collect(static::getFor($page->flatreference()->get())->flatten()->all())->reject(function ($node) { |
||
19 | return !$node->online; |
||
20 | }); |
||
21 | } |
||
22 | |||
23 | public static function getGrandParentForPage(Page $page) |
||
24 | { |
||
25 | /** @var NodeCollection $tree */ |
||
26 | $tree = static::getFor($page->flatreference()->get()); |
||
27 | |||
28 | if ($tree->first()) { |
||
29 | return $tree->first()->reference; |
||
30 | } |
||
31 | |||
32 | return null; |
||
33 | } |
||
34 | |||
35 | public static function getParentForPage(Page $page) |
||
47 | } |
||
48 | } |
||
49 |