19declare(strict_types=1);
25use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
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();
105 $this->single_identifier_to_handle =
$DIC->http()->request()->getQueryParams()[
self::ITEM_ID] ??
null;
106 $this->toasts =
$DIC->globalScreen()->collector()->toasts()->getToasts();
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());
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) {
143 if ($toast_action->getIdentifier() === $this->additional_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();
Customizing of pimple-DIC for ILIAS.
static ofString(string $string)
Creates a new stream with an initial value.
array $notification_groups
Collected set of collected notifications.
const MODE_CLOSED
Value of the MODE GET param, if the Notification Center has been closed.
const NOTIFICATION_IDENTIFIERS
Used to read the identifiers out of the GET param later.
const MODE_HANDLE_TOAST_ACTION
Value of the MODE GET param, if a ToastLik has been klicked.
const MODE_RERENDER
Value of the MODE GET param, if the Notification Center should be rerendered.
const ITEM_ID
NAME of the GET param, to indicate the item ID of the closed item.
string $single_identifier_to_handle
const NOTIFY_ENDPOINT
Location of the endpoint handling async notification requests.
array $identifiers_to_handle
array $administrative_notifications
const MODE_OPENED
Value of the MODE GET param, if the Notification Center has been opened.
string $additional_action
handleOpened()
Loops through all available open callable provided by the notification providers.
const MODE
Name of the GET param used in the async calls.
handleClosed()
Runs the closed callable if such a callable is provided.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...