ILIAS  release_7 Revision v7.30-3-g800a261c036
AdministrativeNotification.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
21 
26 use Closure;
27 
34 {
35  public const DENOTATION_NEUTRAL = 'neutral';
36  public const DENOTATION_IMPORTANT = 'important';
37  public const DENOTATION_BREAKING = 'breaking';
38 
43 
48 
52  protected $title;
53 
57  protected $summary;
58 
70  protected $is_always_available = false;
74  protected $denotation = self::DENOTATION_NEUTRAL;
75 
80  {
81  return new AdministrativeNotificationRenderer($factory);
82  }
83 
87  public function withTitle(string $title) : hasTitle
88  {
89  $clone = clone $this;
90  $clone->title = $title;
91 
92  return $clone;
93  }
94 
98  public function getTitle() : string
99  {
100  return $this->title;
101  }
102 
106  public function withSummary(string $summary) : isItem
107  {
108  $clone = clone $this;
109  $clone->summary = $summary;
110 
111  return $clone;
112  }
113 
117  public function getSummary() : string
118  {
119  return $this->summary;
120  }
121 
122  public function withVisibilityCallable(callable $is_visible) : self
123  {
124  $clone = clone($this);
125  $clone->visiblility_callable = $is_visible;
126 
127  return $clone;
128  }
129 
130  public function isVisible() : bool
131  {
132  if (isset($this->is_visible_static)) {
134  }
135  if (!$this->isAvailable()) {
136  return $this->is_visible_static = false;
137  }
138  if (is_callable($this->visiblility_callable)) {
139  $callable = $this->visiblility_callable;
140 
141  $value = $callable();
142 
143  return $this->is_visible_static = $value;
144  }
145 
146  return $this->is_visible_static = true;
147  }
148 
149  public function isAvailable() : bool
150  {
151  if (is_callable($this->available_callable)) {
152  $callable = $this->available_callable;
153 
154  return $callable();
155  }
156 
157  return true;
158  }
159 
160  public function withAvailableCallable(callable $is_available) : self
161  {
162  $clone = clone($this);
163  $clone->available_callable = $is_available;
164 
165  return $clone;
166  }
167 
168  public function withNeutralDenotation() : self
169  {
170  $clone = clone($this);
171  $clone->denotation = self::DENOTATION_NEUTRAL;
172 
173  return $clone;
174  }
175 
176  public function withImportantDenotation() : self
177  {
178  $clone = clone($this);
179  $clone->denotation = self::DENOTATION_IMPORTANT;
180 
181  return $clone;
182  }
183 
184  public function withBreakingDenotation() : self
185  {
186  $clone = clone($this);
187  $clone->denotation = self::DENOTATION_BREAKING;
188 
189  return $clone;
190  }
191 
192  public function getDenotation() : string
193  {
194  return $this->denotation ?? self::DENOTATION_NEUTRAL;
195  }
196 }
Interface NotificationRenderer Every Notification should have a renderer, if you won&#39;t provide on in ...
$factory
Definition: metadata.php:58