ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Notifications\Provider\NotificationsToastProvider Class Reference
+ Inheritance diagram for ILIAS\Notifications\Provider\NotificationsToastProvider:
+ Collaboration diagram for ILIAS\Notifications\Provider\NotificationsToastProvider:

Public Member Functions

 getToasts ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Toast\Provider\AbstractToastProvider
 __construct (Container $dic)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 

Protected Member Functions

 getIconByType (string $type)
 
- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Toast\Provider\AbstractToastProvider
Container $dic
 
ILIAS UI Factory $ui_factory
 
IdentificationProviderInterface $if
 
ToastFactory $toast_factory
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
Container $dic
 

Detailed Description

Author
Ingmar Szmais iszma.nosp@m.is@d.nosp@m.ataba.nosp@m.y.de

Definition at line 37 of file NotificationsToastProvider.php.

Member Function Documentation

◆ getIconByType()

ILIAS\Notifications\Provider\NotificationsToastProvider::getIconByType ( string  $type)
protected

◆ getToasts()

ILIAS\Notifications\Provider\NotificationsToastProvider::getToasts ( )

Implements ILIAS\GlobalScreen\Scope\Toast\Provider\ToastProvider.

Definition at line 42 of file NotificationsToastProvider.php.

References $id, ILIAS\LTI\ToolProvider\$settings, $type, ILIAS\UI\Implementation\Component\Toast\Toast\DEFAULT_DELAY_TIME, ILIAS\UI\Implementation\Component\Toast\Toast\DEFAULT_VANISH_TIME, ILIAS\Notifications\Provider\NotificationsToastProvider\getIconByType(), and if.

42  : array
43  {
44  $settings = new ilSetting('notifications');
45  $toasts = [];
46 
47  $osd_repository = new ilNotificationOSDRepository($this->dic->database());
48  $osd_notification_handler = new ilNotificationOSDHandler($osd_repository);
49 
50  foreach ($osd_notification_handler->getOSDNotificationsForUser(
51  $this->dic->user()->getId(),
52  true,
53  time() - ($this->dic->http()->request()->getQueryParams()['max_age'] ?? time())
54  ) as $notification) {
55  $type = $notification->getType();
56  $toast = $this->toast_factory
57  ->standard(
58  $this->if->identifier((string) $notification->getId()),
59  $notification->getObject()->title
60  )
61  ->withIcon($this->getIconByType($notification->getType()))
62  ->withDescription($notification->getObject()->shortDescription)
63  ->withVanishTime((int) $settings->get('osd_vanish', (string) Toast::DEFAULT_VANISH_TIME))
64  ->withDelayTime((int) $settings->get('osd_delay', (string) Toast::DEFAULT_DELAY_TIME))
65  ->withClosedCallable(static function () use ($osd_repository, $notification) {
66  $osd_repository->deleteOSDNotificationById($notification->getId());
67  });
68 
69  foreach ($notification->getObject()->links as $id => $link) {
70  $toast = $toast->withAdditionToastAction(
71  $this->toast_factory->action(
72  $notification->getId() . '_link_' . $id,
73  $link->getTitle(),
74  function () use ($link, $osd_repository, $notification): void {
75  $osd_repository->deleteOSDNotificationById($notification->getId());
76  $this->dic->ctrl()->redirectToURL($link->getUrl());
77  }
78  )
79  );
80  }
81  $toasts[] = $toast;
82  }
83 
84  return $toasts;
85  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$type
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

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