ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables 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;
32 
38 {
40  use isSupportedTrait;
41 
45  protected $ui;
46 
50  public function __construct()
51  {
52  global $DIC;
53  $this->ui = $DIC->ui();
54  }
55 
60  protected function getURI(string $uri_string) : URI
61  {
62  if (strpos($uri_string, 'http') === 0) {
63  return new URI($uri_string);
64  }
65 
66  return new URI(rtrim(ILIAS_HTTP_PATH, "/") . "/" . ltrim($uri_string, "./"));
67  }
68 
72  public function getComponentForItem(isItem $item) : Component
73  {
74  $component = $this->getSpecificComponentForItem($item);
75 
76  return $this->applyDecorator($component, $item);
77  }
78 
79  abstract protected function getSpecificComponentForItem(isItem $item) : Component;
80 
85  protected function buildIcon(isItem $item) : Symbol
86  {
87  if ($item instanceof hasSymbol && $item->hasSymbol()) {
88  return $this->applySymbolDecorator($item->getSymbol(), $item);
89  }
90  if ($item instanceof hasTitle) {
91  $abbr = strtoupper(substr($item->getTitle(), 0, 1));
92  } else {
93  $abbr = strtoupper(substr(uniqid('', true), -1));
94  }
95 
96  return $this->ui->factory()->symbol()->icon()->standard($abbr, $abbr, 'small', true)->withAbbreviation($abbr);
97  }
98 
102  protected function getStandardSymbol(isItem $item) : Symbol
103  {
104  return $this->buildIcon($item);
105  }
106 }
This describes a symbol.
Definition: Symbol.php:11
global $DIC
Definition: goto.php:24
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:17
ui()
Definition: ui.php:5