ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TopParentItemDrilldownRenderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
32
38{
39 #[\Override]
41 {
42 $entries = [];
43 foreach ($item->getChildren() as $child) {
44 if (!$child->isVisible()) {
45 continue;
46 }
47 $component = $this->buildEntry($child, $item);
48 if ($component === null) {
49 continue;
50 }
51 $entries[] = $component;
52 }
53
54 $dd = $this->ui_factory->menu()->drilldown($item->getTitle(), $entries);
55
56 $slate = $this->ui_factory->mainControls()->slate()->drilldown(
57 $item->getTitle(),
58 $this->getStandardSymbol($item),
59 $dd
60 );
61
62 return $slate;
63 }
64
65 protected function buildEntry(AbstractChildItem $item, isTopItem $parent): ?Component
66 {
67 $title = $item->getTitle();
68 $symbol = $this->getStandardSymbol($item);
69 $type = $item::class;
70
71 switch ($type) {
72 case RepositoryLink::class:
73 case Link::class:
74 // try if the link is already e valid URI
75 try {
76 $act = $this->getDataFactory()->uri($item->getAction());
77 } catch (\Throwable) {
78 $act = $this->getDataFactory()->uri(
79 $this->getBaseURL()
80 . '/'
81 . $item->getAction()
82 );
83 }
84
85 $entry = $this->ui_factory->link()->bulky($symbol, $title, $act);
86 break;
87
88 case LinkList::class:
89 $links = [];
90 foreach ($item->getLinks() as $child) {
91 if (!$child->isVisible()) {
92 continue;
93 }
94 $links[] = $this->buildEntry($child, $parent);
95 }
96 $entry = $this->ui_factory->menu()->sub($title, $links);
97 break;
98 case Separator::class:
99 $entry = $this->ui_factory->divider()->horizontal()->withLabel($title);
100 break;
101
102 default:
103 $entry = $this->ui_factory->divider()->horizontal()->withLabel(
104 sprintf($this->txt('unable_to_render'), $title, $parent->getTitle())
105 );
106 }
107
108 return $entry;
109 }
110
111 protected function getDataFactory(): Factory
112 {
113 return new Factory();
114 }
115
116 private function getBaseURL(): string
117 {
118 return ILIAS_HTTP_PATH;
119 }
120
121 private function txt(string $key): string
122 {
123 return $this->lng->txt($key);
124 }
125}
Builds data types.
Definition: Factory.php:36
getComponentWithContent(isItem $item)
This is called in cases when the Full Item with it's content is needed, e.g.
A component is the most general form of an entity in the UI.
Definition: Component.php:28