ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
GuzzleHttp\Client\Notifications Class Reference
+ Collaboration diagram for GuzzleHttp\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_HANDLE_TOAST_ACTION = "toast_action"
 Value of the MODE GET param, if a ToastLik has been klicked. 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 = "notify.php"
 Location of the endpoint handling async notification requests. More...
 

Protected Attributes

Container $dic
 
array $notification_groups
 Collected set of collected notifications. More...
 
array $identifiers_to_handle = []
 
string $single_identifier_to_handle = null
 
array $administrative_notifications = []
 

Private Member Functions

 handleToastAction ()
 
 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

string $additional_action = null
 
array $toasts = []
 

Detailed Description

Definition at line 36 of file Notifications.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Client\Notifications::__construct ( )

Definition at line 90 of file Notifications.php.

References $DIC.

91  {
92  global $DIC;
93  $this->dic = $DIC;
94  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ handleClosed()

GuzzleHttp\Client\Notifications::handleClosed ( )
private

Runs the closed callable if such a callable is provided.

Definition at line 183 of file Notifications.php.

Referenced by GuzzleHttp\Client\Notifications\run().

183  : void
184  {
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()
189  )) {
190  continue;
191  }
192  if (!$notification->hasClosedCallable()) {
193  continue;
194  }
195  $notification->getClosedCallable()();
196  }
197  }
198  foreach ($this->administrative_notifications as $administrative_notification) {
199  if ($this->single_identifier_to_handle !== $this->hash(
200  $administrative_notification->getProviderIdentification()->serialize()
201  )) {
202  continue;
203  }
204  if (!$administrative_notification->hasClosedCallable()) {
205  continue;
206  }
207  $administrative_notification->getClosedCallable()();
208  }
209  }
+ Here is the caller graph for this function:

◆ handleOpened()

GuzzleHttp\Client\Notifications::handleOpened ( )
private

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

Definition at line 158 of file Notifications.php.

Referenced by GuzzleHttp\Client\Notifications\run().

158  : void
159  {
160  foreach ($this->notification_groups as $notification_group) {
161  foreach ($notification_group->getNotifications() as $notification) {
162  if (in_array(
163  $this->hash($notification->getProviderIdentification()->serialize()),
164  $this->identifiers_to_handle,
165  true
166  )) {
167  $notification->getOpenedCallable()();
168  }
169  }
170  if (in_array(
171  $this->hash($notification_group->getProviderIdentification()->serialize()),
172  $this->identifiers_to_handle,
173  true
174  )) {
175  $notification_group->getOpenedCallable()();
176  }
177  }
178  }
+ Here is the caller graph for this function:

◆ handleRerender()

GuzzleHttp\Client\Notifications::handleRerender ( )
private
Exceptions
ResponseSendingException
JsonException

Definition at line 215 of file Notifications.php.

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

Referenced by GuzzleHttp\Client\Notifications\run().

215  : void
216  {
217  $notifications = [];
218  $amount = 0;
219  foreach ($this->notification_groups as $group) {
220  $notifications[] = $group->getRenderer($this->dic->ui()->factory())->getNotificationComponentForItem(
221  $group
222  );
223  if ($group->getNewNotificationsCount() > 0) {
224  $amount++;
225  }
226  }
227  $this->dic->http()->saveResponse(
228  $this->dic->http()->response()
229  ->withBody(
231  json_encode([
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)
236  )
237  )
238  ], JSON_THROW_ON_ERROR)
239  )
240  )
241  ->withHeader(ResponseHeader::CONTENT_TYPE, 'application/json')
242  );
243  $this->dic->http()->sendResponse();
244  $this->dic->http()->close();
245  }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleToastAction()

GuzzleHttp\Client\Notifications::handleToastAction ( )
private

Definition at line 139 of file Notifications.php.

References GuzzleHttp\Client\Notifications\$additional_action.

Referenced by GuzzleHttp\Client\Notifications\run().

139  : void
140  {
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();
146  $callable();
147  return;
148  }
149  }
150  }
151  }
152  }
+ Here is the caller graph for this function:

◆ run()

GuzzleHttp\Client\Notifications::run ( )

$DI

Definition at line 96 of file Notifications.php.

References $DIC, GuzzleHttp\Client\Notifications\handleClosed(), GuzzleHttp\Client\Notifications\handleOpened(), GuzzleHttp\Client\Notifications\handleRerender(), GuzzleHttp\Client\Notifications\handleToastAction(), and null.

96  : void
97  {
101  global $DIC;
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();
108 
109  $query = $DIC->http()->wrapper()->query();
110 
111  $this->additional_action = $query->has(self::ADDITIONAL_ACTION)
112  ? $query->retrieve(
113  self::ADDITIONAL_ACTION,
114  $DIC->refinery()->kindlyTo()->string()
115  )
116  : null;
117 
118  $mode = 'none';
119  if ($query->has(self::MODE)) {
120  $mode = $query->retrieve(self::MODE, $DIC->refinery()->to()->string());
121  }
122 
123  switch ($mode) {
124  case self::MODE_OPENED:
125  $this->handleOpened();
126  break;
127  case self::MODE_CLOSED:
128  $this->handleClosed();
129  break;
130  case self::MODE_RERENDER:
131  $this->handleRerender();
132  break;
133  case self::MODE_HANDLE_TOAST_ACTION:
134  $this->handleToastAction();
135  break;
136  }
137  }
handleClosed()
Runs the closed callable if such a callable is provided.
handleOpened()
Loops through all available open callable provided by the notification providers. ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Field Documentation

◆ $additional_action

string GuzzleHttp\Client\Notifications::$additional_action = null
private

Definition at line 44 of file Notifications.php.

Referenced by GuzzleHttp\Client\Notifications\handleToastAction().

◆ $administrative_notifications

array GuzzleHttp\Client\Notifications::$administrative_notifications = []
protected

Definition at line 84 of file Notifications.php.

◆ $dic

Container GuzzleHttp\Client\Notifications::$dic
protected

Definition at line 45 of file Notifications.php.

◆ $identifiers_to_handle

array GuzzleHttp\Client\Notifications::$identifiers_to_handle = []
protected

Definition at line 82 of file Notifications.php.

◆ $notification_groups

array GuzzleHttp\Client\Notifications::$notification_groups
protected

Collected set of collected notifications.

Definition at line 49 of file Notifications.php.

◆ $single_identifier_to_handle

string GuzzleHttp\Client\Notifications::$single_identifier_to_handle = null
protected

Definition at line 83 of file Notifications.php.

◆ $toasts

array GuzzleHttp\Client\Notifications::$toasts = []
private

Definition at line 88 of file Notifications.php.

◆ ADDITIONAL_ACTION

const GuzzleHttp\Client\Notifications::ADDITIONAL_ACTION = 'additional_action'

Definition at line 40 of file Notifications.php.

◆ ITEM_ID

const GuzzleHttp\Client\Notifications::ITEM_ID = "item_id"

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

Definition at line 73 of file Notifications.php.

◆ MODE

const GuzzleHttp\Client\Notifications::MODE = "mode"

Name of the GET param used in the async calls.

Definition at line 53 of file Notifications.php.

◆ MODE_CLOSED

const GuzzleHttp\Client\Notifications::MODE_CLOSED = "closed"

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

Definition at line 61 of file Notifications.php.

◆ MODE_HANDLE_TOAST_ACTION

const GuzzleHttp\Client\Notifications::MODE_HANDLE_TOAST_ACTION = "toast_action"

Value of the MODE GET param, if a ToastLik has been klicked.

Definition at line 65 of file Notifications.php.

◆ MODE_OPENED

const GuzzleHttp\Client\Notifications::MODE_OPENED = "opened"

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

Definition at line 57 of file Notifications.php.

◆ MODE_RERENDER

const GuzzleHttp\Client\Notifications::MODE_RERENDER = "rerender"

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

Definition at line 69 of file Notifications.php.

◆ NOTIFICATION_IDENTIFIERS

const GuzzleHttp\Client\Notifications::NOTIFICATION_IDENTIFIERS = "notification_identifiers"

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

Definition at line 77 of file Notifications.php.

◆ NOTIFY_ENDPOINT

const GuzzleHttp\Client\Notifications::NOTIFY_ENDPOINT = "notify.php"

Location of the endpoint handling async notification requests.

Definition at line 81 of file Notifications.php.


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