19 declare(strict_types=1);
53 public const MODE =
"mode";
96 public function run(): void
102 $this->notification_groups = $DIC->globalScreen()->collector()->notifications()->getNotifications();
103 $this->administrative_notifications = $DIC->globalScreen()->collector()->notifications(
104 )->getAdministrativeNotifications();
105 $this->identifiers_to_handle = $DIC->http()->request()->getQueryParams()[self::NOTIFICATION_IDENTIFIERS] ?? [];
106 $this->single_identifier_to_handle = $DIC->http()->request()->getQueryParams()[self::ITEM_ID] ??
null;
107 $this->toasts = $DIC->globalScreen()->collector()->toasts()->getToasts();
109 $query = $DIC->http()->wrapper()->query();
111 $this->additional_action = $query->has(self::ADDITIONAL_ACTION)
113 self::ADDITIONAL_ACTION,
114 $DIC->refinery()->kindlyTo()->string()
119 if ($query->has(self::MODE)) {
120 $mode = $query->retrieve(self::MODE, $DIC->refinery()->to()->string());
124 case self::MODE_OPENED:
127 case self::MODE_CLOSED:
130 case self::MODE_RERENDER:
133 case self::MODE_HANDLE_TOAST_ACTION:
141 foreach ($this->toasts as $toast) {
142 if ($this->
hash($toast->getProviderIdentification()->serialize()) === $this->single_identifier_to_handle) {
143 foreach ($toast->getAllToastActions() as $toast_action) {
145 $callable = $toast_action->getAction();
160 foreach ($this->notification_groups as $notification_group) {
161 foreach ($notification_group->getNotifications() as $notification) {
163 $this->
hash($notification->getProviderIdentification()->serialize()),
164 $this->identifiers_to_handle,
167 $notification->getOpenedCallable()();
171 $this->
hash($notification_group->getProviderIdentification()->serialize()),
172 $this->identifiers_to_handle,
175 $notification_group->getOpenedCallable()();
185 foreach ($this->notification_groups as $notification_group) {
186 foreach ($notification_group->getNotifications() as $notification) {
187 if ($this->single_identifier_to_handle !== $this->
hash(
188 $notification->getProviderIdentification()->serialize()
192 if (!$notification->hasClosedCallable()) {
195 $notification->getClosedCallable()();
198 foreach ($this->administrative_notifications as $administrative_notification) {
199 if ($this->single_identifier_to_handle !== $this->
hash(
200 $administrative_notification->getProviderIdentification()->serialize()
204 if (!$administrative_notification->hasClosedCallable()) {
207 $administrative_notification->getClosedCallable()();
219 foreach ($this->notification_groups as $group) {
220 $notifications[] = $group->getRenderer($this->dic->ui()->factory())->getNotificationComponentForItem(
223 if ($group->getNewNotificationsCount() > 0) {
227 $this->dic->http()->saveResponse(
228 $this->dic->http()->response()
232 'html' => $this->dic->ui()->renderer()->renderAsync($notifications),
233 'symbol' => $this->dic->ui()->renderer()->render(
234 $this->dic->ui()->factory()->symbol()->glyph()->notification()->withCounter(
235 $this->dic->ui()->factory()->counter()->novelty($amount)
238 ], JSON_THROW_ON_ERROR)
243 $this->dic->http()->sendResponse();
244 $this->dic->http()->close();
handleClosed()
Runs the closed callable if such a callable is provided.
handleOpened()
Loops through all available open callable provided by the notification providers. ...
const ITEM_ID
NAME of the GET param, to indicate the item ID of the closed item.
const MODE_RERENDER
Value of the MODE GET param, if the Notification Center should be rerendered.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $administrative_notifications
const MODE_OPENED
Value of the MODE GET param, if the Notification Center has been opened.
const MODE_CLOSED
Value of the MODE GET param, if the Notification Center has been closed.
array $identifiers_to_handle
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
string $additional_action
const NOTIFICATION_IDENTIFIERS
Used to read the identifiers out of the GET param later.
string $single_identifier_to_handle
const MODE
Name of the GET param used in the async calls.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ofString(string $string)
Creates a new stream with an initial value.
const MODE_HANDLE_TOAST_ACTION
Value of the MODE GET param, if a ToastLik has been klicked.
array $notification_groups
Collected set of collected notifications.
const NOTIFY_ENDPOINT
Location of the endpoint handling async notification requests.