ILIAS  release_7 Revision v7.30-3-g800a261c036
AbstractMetaBarItemRenderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\GlobalScreen\Collector\Renderer\ComponentDecoratorApplierTrait;
26use ILIAS\GlobalScreen\Collector\Renderer\isSupportedTrait;
32
38{
39 use ComponentDecoratorApplierTrait;
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}
An exception for terminatinating execution or to throw for unit testing.
Provides fluid interface to RBAC services.
Definition: UIServices.php:10
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
global $DIC
Definition: goto.php:24
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This describes a symbol.
Definition: Symbol.php:12
ui()
Definition: ui.php:5