ILIAS  release_7 Revision v7.30-3-g800a261c036
TopParentItemDrilldownRenderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use Exception;
30
36{
37 public function getComponentWithContent(isItem $item) : Component
38 {
39 $entries = [];
40 foreach ($item->getChildren() as $child) {
41 $entries[] = $this->buildEntry($child);
42 }
43
44 $dd = $this->ui_factory->menu()->drilldown($item->getTitle(), $entries);
45
46 return $this->ui_factory->mainControls()->slate()->drilldown(
47 $item->getTitle(),
48 $this->getStandardSymbol($item),
49 $dd
50 );
51 }
52
53 protected function buildEntry(AbstractChildItem $item) : Component
54 {
55 $title = $item->getTitle();
56 $symbol = $this->getStandardSymbol($item);
57 $type = get_class($item);
58
59 switch ($type) {
60 case Link::class:
61 $act = $this->getDataFactory()->uri(
62 $this->getBaseURL()
63 . '/'
64 . $item->getAction()
65 );
66 $entry = $this->ui_factory->link()->bulky($symbol, $title, $act);
67 break;
68
69 case LinkList::class:
70 $links = [];
71 foreach ($item->getLinks() as $child) {
72 $links[] = $this->buildEntry($child);
73 }
74 $entry = $this->ui_factory->menu()->sub($title, $links);
75 break;
76
77 default:
78 throw new Exception("Invalid type: " . $type, 1);
79 }
80
81 return $entry;
82 }
83
84 protected function getDataFactory() : Factory
85 {
86 return new Factory();
87 }
88
89 private function getBaseURL() : string
90 {
91 return ILIAS_HTTP_PATH;
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
A component is the most general form of an entity in the UI.
Definition: Component.php:14
$type