Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Core/SignalSlot/NotificationService.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace eZ\Publish\Core\SignalSlot;
10
11 use eZ\Publish\API\Repository\NotificationService as NotificationServiceInterface;
12 use eZ\Publish\API\Repository\Values\Notification\CreateStruct;
13 use eZ\Publish\API\Repository\Values\Notification\Notification;
14 use eZ\Publish\API\Repository\Values\Notification\NotificationList;
15 use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationDeleteSignal;
16 use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationCreateSignal;
17 use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationReadSignal;
18
19 class NotificationService implements NotificationServiceInterface
20 {
22 protected $service;
23
25 protected $signalDispatcher;
26
31 public function __construct(NotificationServiceInterface $service, SignalDispatcher $signalDispatcher)
32 {
33 $this->service = $service;
34 $this->signalDispatcher = $signalDispatcher;
35 }
36
40 public function loadNotifications(int $offset, int $limit): NotificationList
41 {
42 return $this->service->loadNotifications($offset, $limit);
43 }
44
48 public function getNotification(int $notificationId): Notification
49 {
50 return $this->service->getNotification($notificationId);
51 }
52
56 public function markNotificationAsRead(Notification $notification): void
57 {
58 $this->signalDispatcher->emit(new NotificationReadSignal([
59 'notificationId' => $notification->id,
60 ]));
61
62 $this->service->markNotificationAsRead($notification);
63 }
64
68 public function getPendingNotificationCount(): int
69 {
70 return $this->service->getPendingNotificationCount();
71 }
72
76 public function getNotificationCount(): int
77 {
78 return $this->service->getNotificationCount();
79 }
80
84 public function deleteNotification(Notification $notification): void
85 {
86 $this->signalDispatcher->emit(new NotificationDeleteSignal([
87 'notificationId' => $notification->id,
88 ]));
89
90 $this->service->deleteNotification($notification);
91 }
92
96 public function createNotification(CreateStruct $createStruct): Notification
97 {
98 $this->signalDispatcher->emit(new NotificationCreateSignal([
99 'ownerId' => $createStruct->ownerId,
100 'type' => $createStruct->type,
101 'data' => $createStruct->data,
102 ]));
103
104 return $this->service->createNotification($createStruct);
105 }
106 }
eZ\Publish\API\Repository\Values\Notification\CreateStruct
Definition: API/Repository/Values/Notification/CreateStruct.php:14
eZ\Publish\API\Repository\Values\Notification\NotificationList
Definition: NotificationList.php:16
eZ\Publish\API\Repository\Values\Notification\Notification
Definition: API/Repository/Values/Notification/Notification.php:24
eZ\Publish\Core\SignalSlot\NotificationService
Definition: Core/SignalSlot/NotificationService.php:20
eZ\Publish\Core\SignalSlot\NotificationService\getNotification
getNotification(int $notificationId)
{Load single notification (by ID).Notification ID}
Definition: Core/SignalSlot/NotificationService.php:48
eZ\Publish\Core\SignalSlot\NotificationService\createNotification
createNotification(CreateStruct $createStruct)
{Creates a new notification.}
Definition: Core/SignalSlot/NotificationService.php:96
eZ\Publish\Core\SignalSlot\NotificationService\$signalDispatcher
$signalDispatcher
Definition: Core/SignalSlot/NotificationService.php:25
eZ\Publish\Core\SignalSlot\NotificationService\deleteNotification
deleteNotification(Notification $notification)
{Deletes a notification.}
Definition: Core/SignalSlot/NotificationService.php:84
eZ\Publish\Core\SignalSlot\NotificationService\loadNotifications
loadNotifications(int $offset, int $limit)
{Get currently logged user notifications.the start offset for paging the number of notifications retu...
Definition: Core/SignalSlot/NotificationService.php:40
eZ\Publish\Core\SignalSlot\NotificationService\__construct
__construct(NotificationServiceInterface $service, SignalDispatcher $signalDispatcher)
Definition: Core/SignalSlot/NotificationService.php:31
eZ\Publish\Core\SignalSlot\NotificationService\markNotificationAsRead
markNotificationAsRead(Notification $notification)
{Mark notification as read so it no longer bother the user.}
Definition: Core/SignalSlot/NotificationService.php:56
eZ\Publish\Core\SignalSlot\NotificationService\getPendingNotificationCount
getPendingNotificationCount()
{Get count of unread users notifications.int}
Definition: Core/SignalSlot/NotificationService.php:68
eZ\Publish\Core\SignalSlot\NotificationService\getNotificationCount
getNotificationCount()
{Get count of total users notifications.int}
Definition: Core/SignalSlot/NotificationService.php:76
eZ\Publish\Core\SignalSlot\NotificationService\$service
$service
Definition: Core/SignalSlot/NotificationService.php:22
eZ\Publish\Core\SignalSlot\SignalDispatcher
Dispatches Signals to their assigned Slots.
Definition: SignalDispatcher.php:20
eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationCreateSignal
Definition: NotificationCreateSignal.php:14
eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationDeleteSignal
Definition: NotificationDeleteSignal.php:14
eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationReadSignal
Definition: NotificationReadSignal.php:14
eZ\Publish\API\Repository\NotificationService
Service to manager user notifications.
Definition: API/Repository/NotificationService.php:20
eZ\Publish\Core\SignalSlot
Definition: Core/SignalSlot/BookmarkService.php:9
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.