ILIAS  release_8 Revision v8.19
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 
42  protected UIServices $ui;
43 
47  public function __construct()
48  {
49  global $DIC;
50  $this->ui = $DIC->ui();
51  }
52 
57  protected function getURI(string $uri_string): URI
58  {
59  if (strpos($uri_string, 'http') === 0) {
60  return new URI($uri_string);
61  }
62 
63  return new URI(rtrim(ILIAS_HTTP_PATH, "/") . "/" . ltrim($uri_string, "./"));
64  }
65 
69  public function getComponentForItem(isItem $item): Component
70  {
71  $component = $this->getSpecificComponentForItem($item);
72 
73  return $this->applyDecorator($component, $item);
74  }
75 
76  abstract protected function getSpecificComponentForItem(isItem $item): Component;
77 
82  protected function buildIcon(isItem $item): Symbol
83  {
84  if ($item instanceof hasSymbol && $item->hasSymbol()) {
85  return $this->applySymbolDecorator($item->getSymbol(), $item);
86  }
87  if ($item instanceof hasTitle) {
88  $abbr = strtoupper(substr($item->getTitle(), 0, 1));
89  } else {
90  $abbr = strtoupper(substr(uniqid('', true), -1));
91  }
92 
93  return $this->ui->factory()->symbol()->icon()->standard($abbr, $abbr, 'small', true)->withAbbreviation($abbr);
94  }
95 }
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...
global $DIC
Definition: feed.php:28
Provides fluid interface to RBAC services.
Definition: UIServices.php:23
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34