ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AdministrativeNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\UI\Factory as UIFactory;
27use Closure;
28
35{
36 public const DENOTATION_NEUTRAL = 'neutral';
37 public const DENOTATION_IMPORTANT = 'important';
38 public const DENOTATION_BREAKING = 'breaking';
39
40 private bool $is_visible_static;
41
43
44 protected string $title;
45
46 protected string $summary;
47
48 protected ?Closure $available_callable = null;
49 protected ?Closure $visiblility_callable = null;
50 protected bool $is_always_available = false;
52
56 #[\Override]
57 public function getRenderer(UIFactory $factory): NotificationRenderer
58 {
59 return new AdministrativeNotificationRenderer($factory);
60 }
61
65 public function withTitle(string $title): hasTitle
66 {
67 $clone = clone $this;
68 $clone->title = $title;
69
70 return $clone;
71 }
72
76 public function getTitle(): string
77 {
78 return $this->title;
79 }
80
84 public function withSummary(string $summary): isItem
85 {
86 $clone = clone $this;
87 $clone->summary = $summary;
88
89 return $clone;
90 }
91
95 public function getSummary(): string
96 {
97 return $this->summary;
98 }
99
100 public function withVisibilityCallable(callable $is_visible): self
101 {
102 $clone = clone($this);
103 $clone->visiblility_callable = $is_visible;
104
105 return $clone;
106 }
107
108 public function isVisible(): bool
109 {
110 if (isset($this->is_visible_static)) {
112 }
113 if (!$this->isAvailable()) {
114 return $this->is_visible_static = false;
115 }
116 if (is_callable($this->visiblility_callable)) {
117 $callable = $this->visiblility_callable;
118
119 $value = $callable();
120
121 return $this->is_visible_static = $value;
122 }
123
124 return $this->is_visible_static = true;
125 }
126
127 public function isAvailable(): bool
128 {
129 if (is_callable($this->available_callable)) {
130 $callable = $this->available_callable;
131
132 return $callable();
133 }
134
135 return true;
136 }
137
138 public function withAvailableCallable(callable $is_available): self
139 {
140 $clone = clone($this);
141 $clone->available_callable = $is_available;
142
143 return $clone;
144 }
145
146 public function withNeutralDenotation(): self
147 {
148 $clone = clone($this);
149 $clone->denotation = self::DENOTATION_NEUTRAL;
150
151 return $clone;
152 }
153
154 public function withImportantDenotation(): self
155 {
156 $clone = clone($this);
157 $clone->denotation = self::DENOTATION_IMPORTANT;
158
159 return $clone;
160 }
161
162 public function withBreakingDenotation(): self
163 {
164 $clone = clone($this);
165 $clone->denotation = self::DENOTATION_BREAKING;
166
167 return $clone;
168 }
169
170 public function getDenotation(): string
171 {
172 return $this->denotation ?? self::DENOTATION_NEUTRAL;
173 }
174}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Interface NotificationRenderer Every Notification should have a renderer, if you won't provide on in ...