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