ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
NotificationCenter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
32 {
39 
46 
51  private array $notifications = [];
52 
56  public function __construct(IdentificationInterface $provider_identification)
57  {
58  parent::__construct($provider_identification);
59  $this->renderer = new NotificationCenterRenderer();
60  }
61 
65  public function withNotifications(array $notifications): self
66  {
67  $clone = clone($this);
68  $clone->notifications = $notifications;
69 
70  return $clone;
71  }
72 
76  public function getNotifications(): array
77  {
78  return $this->notifications;
79  }
80 
84  public function withSymbol(Symbol $symbol): hasSymbol
85  {
86  return $this;
87  }
88 
92  public function hasSymbol(): bool
93  {
94  return true;
95  }
96 
100  public function getSymbol(): Symbol
101  {
102  global $DIC;
103 
104  $f = $DIC->ui()->factory();
105  $new = $this->getAmountOfNewNotifications();
106  $old = $this->getAmountOfOldNotifications() - $new;
107  $glyph = $f->symbol()->glyph()->notification()->withCounter($f->counter()->novelty($new));
108  if ($old > 0) {
109  return $glyph->withCounter($f->counter()->status($old));
110  }
111  return $glyph;
112  }
113 
117  public function getPosition(): int
118  {
119  return 1;
120  }
121 
125  public function withAmountOfOldNotifications(int $amount): self
126  {
127  $clone = clone($this);
128  $clone->amount_of_old_notifications = $amount;
129 
130  return $clone;
131  }
132 
137  public function getAmountOfOldNotifications(): int
138  {
140  }
141 
145  public function withAmountOfNewNotifications(int $amount): self
146  {
147  $clone = clone($this);
148  $clone->amount_of_new_notifications = $amount;
149 
150  return $clone;
151  }
152 
157  public function getAmountOfNewNotifications(): int
158  {
160  }
161 }
This describes a symbol.
Definition: Symbol.php:29
getAmountOfNewNotifications()
Get the amount of new notifications.
withAmountOfOldNotifications(int $amount)
Get a Center like this, but with a given amount of old notifications.
__construct(IdentificationInterface $provider_identification)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
withAmountOfNewNotifications(int $amount)
Get a Center like this, but with a given amount of new notifications.
getAmountOfOldNotifications()
Get the amount of old notifications.
__construct(Container $dic, ilPlugin $plugin)