ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AbstractMetaBarItemRenderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\GlobalScreen\Collector\Renderer\DecoratorApplierTrait;
26use ILIAS\GlobalScreen\Collector\Renderer\isSupportedTrait;
33
39{
40 use DecoratorApplierTrait;
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}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This describes a symbol.
Definition: Symbol.php:30
global $DIC
Definition: shib_login.php:26