ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\GlobalScreen\Client\Notifications Class Reference
+ Collaboration diagram for ILIAS\GlobalScreen\Client\Notifications:

Public Member Functions

 __construct ()
 
 run ()
 

Data Fields

const ADDITIONAL_ACTION = 'additional_action'
 
const MODE = "mode"
 Name of the GET param used in the async calls. More...
 
const MODE_OPENED = "opened"
 Value of the MODE GET param, if the Notification Center has been opened. More...
 
const MODE_CLOSED = "closed"
 Value of the MODE GET param, if the Notification Center has been closed. More...
 
const MODE_RERENDER = "rerender"
 Value of the MODE GET param, if the Notification Center should be rerendered. More...
 
const ITEM_ID = "item_id"
 NAME of the GET param, to indicate the item ID of the closed item. More...
 
const NOTIFICATION_IDENTIFIERS = "notification_identifiers"
 Used to read the identifiers out of the GET param later. More...
 
const NOTIFY_ENDPOINT = "src/GlobalScreen/Client/notify.php"
 Location of the endpoint handling async notification requests. More...
 

Protected Attributes

 $dic
 
 $notification_groups
 
 $identifiers_to_handle = []
 
 $single_identifier_to_handle
 
 $administrative_notifications = []
 

Private Member Functions

 handleOpened ()
 Loops through all available open callable provided by the notification providers. More...
 
 handleClosed ()
 Runs the closed callable if such a callable is provided. More...
 
 handleRerender ()
 

Private Attributes

 $additional_action
 

Detailed Description

Definition at line 35 of file Notifications.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\GlobalScreen\Client\Notifications::__construct ( )

Definition at line 94 of file Notifications.php.

95 {
96 global $DIC;
97 $this->dic = $DIC;
98 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ handleClosed()

ILIAS\GlobalScreen\Client\Notifications::handleClosed ( )
private

Runs the closed callable if such a callable is provided.

Definition at line 151 of file Notifications.php.

151 : void
152 {
153 foreach ($this->notification_groups as $notification_group) {
154 foreach ($notification_group->getNotifications() as $notification) {
155 if ($this->single_identifier_to_handle !== $this->hash(
156 $notification->getProviderIdentification()->serialize()
157 )) {
158 continue;
159 }
160 if (!$notification->hasClosedCallable()) {
161 continue;
162 }
163 $notification->getClosedCallable()();
164 }
165 }
166 foreach ($this->administrative_notifications as $administrative_notification) {
167 if ($this->single_identifier_to_handle !== $this->hash(
168 $administrative_notification->getProviderIdentification()->serialize()
169 )) {
170 continue;
171 }
172 if (!$administrative_notification->hasClosedCallable()) {
173 continue;
174 }
175 $administrative_notification->getClosedCallable()();
176 }
177 }

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

+ Here is the caller graph for this function:

◆ handleOpened()

ILIAS\GlobalScreen\Client\Notifications::handleOpened ( )
private

Loops through all available open callable provided by the notification providers.

Definition at line 126 of file Notifications.php.

126 : void
127 {
128 foreach ($this->notification_groups as $notification_group) {
129 foreach ($notification_group->getNotifications() as $notification) {
130 if (in_array(
131 $this->hash($notification->getProviderIdentification()->serialize()),
132 $this->identifiers_to_handle,
133 true
134 )) {
135 $notification->getOpenedCallable()();
136 }
137 }
138 if (in_array(
139 $this->hash($notification_group->getProviderIdentification()->serialize()),
140 $this->identifiers_to_handle,
141 true
142 )) {
143 $notification_group->getOpenedCallable()();
144 }
145 }
146 }

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

+ Here is the caller graph for this function:

◆ handleRerender()

ILIAS\GlobalScreen\Client\Notifications::handleRerender ( )
private
Exceptions
ResponseSendingException
JsonException

Definition at line 183 of file Notifications.php.

183 : void
184 {
185 $notifications = [];
186 $amount = 0;
187 foreach ($this->notification_groups as $group) {
188 $notifications[] = $group->getRenderer($this->dic->ui()->factory())->getNotificationComponentForItem(
189 $group
190 );
191 if ($group->getNewNotificationsCount() > 0) {
192 $amount++;
193 }
194 }
195 $this->dic->http()->saveResponse(
196 $this->dic->http()->response()
197 ->withBody(
199 json_encode([
200 'html' => $this->dic->ui()->renderer()->renderAsync($notifications),
201 'symbol' => $this->dic->ui()->renderer()->render(
202 $this->dic->ui()->factory()->symbol()->glyph()->notification()->withCounter(
203 $this->dic->ui()->factory()->counter()->novelty($amount)
204 )
205 )
206 ])
207 )
208 )
209 ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
210 );
211 $this->dic->http()->sendResponse();
212 $this->dic->http()->close();
213 }
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:25

References ILIAS\HTTP\Response\ResponseHeader\CONTENT_TYPE, and ILIAS\Filesystem\Stream\Streams\ofString().

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ILIAS\GlobalScreen\Client\Notifications::run ( )

Definition at line 100 of file Notifications.php.

100 : void
101 {
102 $this->notification_groups = $this->dic->globalScreen()->collector()->notifications()->getNotifications();
103 $this->administrative_notifications = $this->dic->globalScreen()->collector()->notifications(
104 )->getAdministrativeNotifications();
105 $this->identifiers_to_handle = $this->dic->http()->request()->getQueryParams()[self::NOTIFICATION_IDENTIFIERS] ?? [];
106 $this->single_identifier_to_handle = $this->dic->http()->request()->getQueryParams()[self::ITEM_ID] ?? null;
107
108 switch ($this->dic->http()->request()->getQueryParams()[self::MODE] ?? 'none') {
110 $this->handleOpened();
111 break;
113 $this->handleClosed();
114 break;
116 $this->handleRerender();
117 break;
118
119 }
120 }
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_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.
const MODE_OPENED
Value of the MODE GET param, if the Notification Center has been opened.
handleOpened()
Loops through all available open callable provided by the notification providers.
handleClosed()
Runs the closed callable if such a callable is provided.

References ILIAS\GlobalScreen\Client\Notifications\handleClosed(), ILIAS\GlobalScreen\Client\Notifications\handleOpened(), ILIAS\GlobalScreen\Client\Notifications\handleRerender(), ILIAS\GlobalScreen\Client\Notifications\ITEM_ID, ILIAS\GlobalScreen\Client\Notifications\MODE_CLOSED, ILIAS\GlobalScreen\Client\Notifications\MODE_OPENED, ILIAS\GlobalScreen\Client\Notifications\MODE_RERENDER, and ILIAS\GlobalScreen\Client\Notifications\NOTIFICATION_IDENTIFIERS.

+ Here is the call graph for this function:

Field Documentation

◆ $additional_action

ILIAS\GlobalScreen\Client\Notifications::$additional_action
private

Definition at line 43 of file Notifications.php.

◆ $administrative_notifications

ILIAS\GlobalScreen\Client\Notifications::$administrative_notifications = []
protected

Definition at line 92 of file Notifications.php.

◆ $dic

ILIAS\GlobalScreen\Client\Notifications::$dic
protected

Definition at line 47 of file Notifications.php.

◆ $identifiers_to_handle

ILIAS\GlobalScreen\Client\Notifications::$identifiers_to_handle = []
protected

Definition at line 84 of file Notifications.php.

◆ $notification_groups

ILIAS\GlobalScreen\Client\Notifications::$notification_groups
protected

Definition at line 52 of file Notifications.php.

◆ $single_identifier_to_handle

ILIAS\GlobalScreen\Client\Notifications::$single_identifier_to_handle
protected

Definition at line 88 of file Notifications.php.

◆ ADDITIONAL_ACTION

const ILIAS\GlobalScreen\Client\Notifications::ADDITIONAL_ACTION = 'additional_action'

Definition at line 39 of file Notifications.php.

◆ ITEM_ID

const ILIAS\GlobalScreen\Client\Notifications::ITEM_ID = "item_id"

NAME of the GET param, to indicate the item ID of the closed item.

Definition at line 72 of file Notifications.php.

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

◆ MODE

const ILIAS\GlobalScreen\Client\Notifications::MODE = "mode"

Name of the GET param used in the async calls.

Definition at line 56 of file Notifications.php.

◆ MODE_CLOSED

const ILIAS\GlobalScreen\Client\Notifications::MODE_CLOSED = "closed"

Value of the MODE GET param, if the Notification Center has been closed.

Definition at line 64 of file Notifications.php.

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

◆ MODE_OPENED

const ILIAS\GlobalScreen\Client\Notifications::MODE_OPENED = "opened"

Value of the MODE GET param, if the Notification Center has been opened.

Definition at line 60 of file Notifications.php.

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

◆ MODE_RERENDER

const ILIAS\GlobalScreen\Client\Notifications::MODE_RERENDER = "rerender"

Value of the MODE GET param, if the Notification Center should be rerendered.

Definition at line 68 of file Notifications.php.

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

◆ NOTIFICATION_IDENTIFIERS

const ILIAS\GlobalScreen\Client\Notifications::NOTIFICATION_IDENTIFIERS = "notification_identifiers"

Used to read the identifiers out of the GET param later.

Definition at line 76 of file Notifications.php.

Referenced by ILIAS\GlobalScreen\Client\Notifications\run().

◆ NOTIFY_ENDPOINT

const ILIAS\GlobalScreen\Client\Notifications::NOTIFY_ENDPOINT = "src/GlobalScreen/Client/notify.php"

Location of the endpoint handling async notification requests.

Definition at line 80 of file Notifications.php.


The documentation for this class was generated from the following file: