ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
AbstractMetaBarItemRenderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ILIAS\Data\URI;
33 
39 {
41  use isSupportedTrait;
42 
43  protected UIServices $ui;
44 
48  public function __construct()
49  {
50  global $DIC;
51  $this->ui = $DIC->ui();
52  }
53 
58  protected function getURI(string $uri_string): URI
59  {
60  if (str_starts_with($uri_string, 'http')) {
61  return new URI($uri_string);
62  }
63 
64  return new URI(rtrim(ILIAS_HTTP_PATH, "/") . "/" . ltrim($uri_string, "./"));
65  }
66 
67  public function getComponentForItem(isItem $item): Component
68  {
69  $component = $this->getSpecificComponentForItem($item);
70  $component = $this->applyComponentDecorator($component, $item);
71  if ($component instanceof HasHelpTopics) {
72  return $component->withHelpTopics(...$item->getTopics());
73  }
74 
75  return $component;
76  }
77 
78  abstract protected function getSpecificComponentForItem(isItem $item): Component;
79 
80  protected function buildIcon(isItem $item): Symbol
81  {
82  if ($item instanceof hasSymbol && $item->hasSymbol()) {
83  return $this->applySymbolDecorator($item->getSymbol(), $item);
84  }
85  if ($item instanceof hasTitle) {
86  $abbr = strtoupper(substr($item->getTitle(), 0, 1));
87  } else {
88  $abbr = strtoupper(substr(uniqid('', true), -1));
89  }
90 
91  return $this->ui->factory()->symbol()->icon()->standard($abbr, $abbr, 'small', true)->withAbbreviation($abbr);
92  }
93 }
This describes a symbol.
Definition: Symbol.php:29
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...
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
global $DIC
Definition: shib_login.php:22