19declare(strict_types=1);
26use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
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();
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());
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) {
144 if ($toast_action->getIdentifier() === $this->additional_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();
Customizing of pimple-DIC for ILIAS.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
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...