ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
NotificationCenter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
34{
36
42
48
53 private array $notifications = [];
54
58 public function __construct(IdentificationInterface $provider_identification)
59 {
60 parent::__construct($provider_identification);
62 }
63
67 public function withNotifications(array $notifications): self
68 {
69 $clone = clone($this);
70 $clone->notifications = $notifications;
71
72 return $clone;
73 }
74
78 public function getNotifications(): array
79 {
81 }
82
86 public function withSymbol(Symbol $symbol): hasSymbol
87 {
88 return $this;
89 }
90
94 public function hasSymbol(): bool
95 {
96 return true;
97 }
98
99 public function getSymbol(): Symbol
100 {
101 global $DIC;
102
103 $f = $DIC->ui()->factory();
104 $new = $this->getAmountOfNewNotifications();
105 $old = $this->getAmountOfOldNotifications() - $new;
106 $glyph = $f->symbol()->glyph()->notification()->withCounter($f->counter()->novelty($new));
107 if ($old > 0) {
108 return $glyph->withCounter($f->counter()->status($old));
109 }
110 return $glyph;
111 }
112
116 #[\Override]
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 {
139 }
140
144 public function withAmountOfNewNotifications(int $amount): self
145 {
146 $clone = clone($this);
147 $clone->amount_of_new_notifications = $amount;
148
149 return $clone;
150 }
151
156 {
158 }
159}
renderer()
getAmountOfNewNotifications()
Get the amount of new notifications.
getAmountOfOldNotifications()
Get the amount of old notifications.
__construct(IdentificationInterface $provider_identification)
@inheritDoc
int $amount_of_old_notifications
Amount of notifications already consulted by the user (will spawn status counters)
withAmountOfNewNotifications(int $amount)
Get a Center like this, but with a given amount of new notifications.
int $amount_of_new_notifications
Amount of notifications not yet consulted by the user (will spawn novelty counters)
withAmountOfOldNotifications(int $amount)
Get a Center like this, but with a given amount of old notifications.
This describes a symbol.
Definition: Symbol.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26