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

Core/Persistence/Legacy/Notification/Handler.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace eZ\Publish\Core\Persistence\Legacy\Notification;
10
11 use eZ\Publish\Core\Base\Exceptions\NotFoundException;
12 use eZ\Publish\SPI\Persistence\Notification\CreateStruct;
13 use eZ\Publish\SPI\Persistence\Notification\Handler as HandlerInterface;
14 use eZ\Publish\SPI\Persistence\Notification\Notification;
15 use eZ\Publish\SPI\Persistence\Notification\UpdateStruct;
16 use eZ\Publish\API\Repository\Values\Notification\Notification as APINotification;
17
18 class Handler implements HandlerInterface
19 {
21 protected $gateway;
22
24 protected $mapper;
25
30 public function __construct(Gateway $gateway, Mapper $mapper)
31 {
32 $this->gateway = $gateway;
33 $this->mapper = $mapper;
34 }
35
41 public function createNotification(CreateStruct $createStruct): Notification
42 {
43 $id = $this->gateway->insert($createStruct);
44
45 return $this->getNotificationById($id);
46 }
47
51 public function countPendingNotifications(int $ownerId): int
52 {
53 return $this->gateway->countUserPendingNotifications($ownerId);
54 }
55
61 public function getNotificationById(int $notificationId): Notification
62 {
63 $notification = $this->mapper->extractNotificationsFromRows(
64 $this->gateway->getNotificationById($notificationId)
65 );
66
67 if (count($notification) < 1) {
68 throw new NotFoundException('Notification', $notificationId);
69 }
70
71 return reset($notification);
72 }
73
80 public function updateNotification(APINotification $apiNotification, UpdateStruct $updateStruct): Notification
81 {
82 $notification = $this->mapper->createNotificationFromUpdateStruct(
83 $updateStruct
84 );
85 $notification->id = $apiNotification->id;
86
87 $this->gateway->updateNotification($notification);
88
89 return $this->getNotificationById($notification->id);
90 }
91
95 public function countNotifications(int $userId): int
96 {
97 return $this->gateway->countUserNotifications($userId);
98 }
99
103 public function loadUserNotifications(int $userId, int $offset, int $limit): array
104 {
105 return $this->mapper->extractNotificationsFromRows(
106 $this->gateway->loadUserNotifications($userId, $offset, $limit)
107 );
108 }
109
113 public function delete(APINotification $notification): void
114 {
115 $this->gateway->delete($notification->id);
116 }
117 }
eZ\Publish\API\Repository\Values\Notification\Notification
Definition: API/Repository/Values/Notification/Notification.php:24
eZ\Publish\Core\Base\Exceptions\NotFoundException
Not Found Exception implementation.
Definition: Core/Base/Exceptions/NotFoundException.php:21
eZ\Publish\Core\Persistence\Legacy\Notification\Gateway
Definition: Persistence/Legacy/Notification/Gateway.php:15
eZ\Publish\Core\Persistence\Legacy\Notification\Handler
Definition: Core/Persistence/Legacy/Notification/Handler.php:19
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\countPendingNotifications
countPendingNotifications(int $ownerId)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:51
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\createNotification
createNotification(CreateStruct $createStruct)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:41
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\__construct
__construct(Gateway $gateway, Mapper $mapper)
Definition: Core/Persistence/Legacy/Notification/Handler.php:30
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\getNotificationById
getNotificationById(int $notificationId)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:61
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\$mapper
$mapper
Definition: Core/Persistence/Legacy/Notification/Handler.php:24
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\$gateway
$gateway
Definition: Core/Persistence/Legacy/Notification/Handler.php:21
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\loadUserNotifications
loadUserNotifications(int $userId, int $offset, int $limit)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:103
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\countNotifications
countNotifications(int $userId)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:95
eZ\Publish\Core\Persistence\Legacy\Notification\Handler\updateNotification
updateNotification(APINotification $apiNotification, UpdateStruct $updateStruct)
{}
Definition: Core/Persistence/Legacy/Notification/Handler.php:80
eZ\Publish\Core\Persistence\Legacy\Notification\Mapper
Definition: Publish/Core/Persistence/Legacy/Notification/Mapper.php:16
eZ\Publish\SPI\Persistence\Notification\CreateStruct
Definition: SPI/Persistence/Notification/CreateStruct.php:14
eZ\Publish\SPI\Persistence\Notification\Notification
Definition: SPI/Persistence/Notification/Notification.php:14
eZ\Publish\SPI\Persistence\Notification\UpdateStruct
Definition: Notification/UpdateStruct.php:14
eZ\Publish\SPI\Persistence\Notification\Handler
Definition: SPI/Persistence/Notification/Handler.php:14
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.