19 declare(strict_types=1);
52 public const MODE =
"mode";
95 public function run(): void
101 $this->notification_groups = $DIC->globalScreen()->collector()->notifications()->getNotifications();
102 $this->administrative_notifications = $DIC->globalScreen()->collector()->notifications(
103 )->getAdministrativeNotifications();
104 $this->identifiers_to_handle = $DIC->http()->request()->getQueryParams()[self::NOTIFICATION_IDENTIFIERS] ?? [];
105 $this->single_identifier_to_handle = $DIC->http()->request()->getQueryParams()[self::ITEM_ID] ?? null;
106 $this->toasts = $DIC->globalScreen()->collector()->toasts()->getToasts();
108 $query = $DIC->http()->wrapper()->query();
110 $this->additional_action =
$query->has(self::ADDITIONAL_ACTION)
112 self::ADDITIONAL_ACTION,
113 $DIC->refinery()->kindlyTo()->string()
118 if (
$query->has(self::MODE)) {
119 $mode =
$query->retrieve(self::MODE, $DIC->refinery()->to()->string());
123 case self::MODE_OPENED:
126 case self::MODE_CLOSED:
129 case self::MODE_RERENDER:
132 case self::MODE_HANDLE_TOAST_ACTION:
140 foreach ($this->toasts as $toast) {
141 if ($this->
hash($toast->getProviderIdentification()->serialize()) === $this->single_identifier_to_handle) {
142 foreach ($toast->getAllToastActions() as $toast_action) {
144 $callable = $toast_action->getAction();
159 foreach ($this->notification_groups as $notification_group) {
160 foreach ($notification_group->getNotifications() as $notification) {
162 $this->
hash($notification->getProviderIdentification()->serialize()),
163 $this->identifiers_to_handle,
166 $notification->getOpenedCallable()();
170 $this->
hash($notification_group->getProviderIdentification()->serialize()),
171 $this->identifiers_to_handle,
174 $notification_group->getOpenedCallable()();
184 foreach ($this->notification_groups as $notification_group) {
185 foreach ($notification_group->getNotifications() as $notification) {
186 if ($this->single_identifier_to_handle !== $this->
hash(
187 $notification->getProviderIdentification()->serialize()
191 if (!$notification->hasClosedCallable()) {
194 $notification->getClosedCallable()();
197 foreach ($this->administrative_notifications as $administrative_notification) {
198 if ($this->single_identifier_to_handle !== $this->
hash(
199 $administrative_notification->getProviderIdentification()->serialize()
203 if (!$administrative_notification->hasClosedCallable()) {
206 $administrative_notification->getClosedCallable()();
218 foreach ($this->notification_groups as $group) {
219 $notifications[] = $group->getRenderer($this->dic->ui()->factory())->getNotificationComponentForItem(
222 if ($group->getNewNotificationsCount() > 0) {
226 $this->dic->http()->saveResponse(
227 $this->dic->http()->response()
231 'html' => $this->dic->ui()->renderer()->renderAsync($notifications),
232 'symbol' => $this->dic->ui()->renderer()->render(
233 $this->dic->ui()->factory()->symbol()->glyph()->notification()->withCounter(
234 $this->dic->ui()->factory()->counter()->novelty($amount)
237 ], JSON_THROW_ON_ERROR)
242 $this->dic->http()->sendResponse();
243 $this->dic->http()->close();
array $administrative_notifications
array $notification_groups
Collected set of collected notifications.
array $identifiers_to_handle
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MODE_CLOSED
Value of the MODE GET param, if the Notification Center has been closed.
const MODE_HANDLE_TOAST_ACTION
Value of the MODE GET param, if a ToastLik has been klicked.
Customizing of pimple-DIC for ILIAS.
const ITEM_ID
NAME of the GET param, to indicate the item ID of the closed item.
string $single_identifier_to_handle
handleOpened()
Loops through all available open callable provided by the notification providers. ...
const NOTIFICATION_IDENTIFIERS
Used to read the identifiers out of the GET param later.
const MODE_OPENED
Value of the MODE GET param, if the Notification Center has been opened.
const NOTIFY_ENDPOINT
Location of the endpoint handling async notification requests.
string $additional_action
const MODE
Name of the GET param used in the async calls.
static ofString(string $string)
Creates a new stream with an initial value.
handleClosed()
Runs the closed callable if such a callable is provided.
const MODE_RERENDER
Value of the MODE GET param, if the Notification Center should be rerendered.