ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  #[\Override]
118  public function getPosition(): int
119  {
120  return 1;
121  }
122 
126  public function withAmountOfOldNotifications(int $amount): self
127  {
128  $clone = clone($this);
129  $clone->amount_of_old_notifications = $amount;
130 
131  return $clone;
132  }
133 
138  public function getAmountOfOldNotifications(): int
139  {
141  }
142 
146  public function withAmountOfNewNotifications(int $amount): self
147  {
148  $clone = clone($this);
149  $clone->amount_of_new_notifications = $amount;
150 
151  return $clone;
152  }
153 
158  public function getAmountOfNewNotifications(): int
159  {
161  }
162 }
This describes a symbol.
Definition: Symbol.php:29
getAmountOfNewNotifications()
Get the amount of new notifications.
renderer()
withAmountOfOldNotifications(int $amount)
Get a Center like this, but with a given amount of old notifications.
__construct(IdentificationInterface $provider_identification)
global $DIC
Definition: shib_login.php:22
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)