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

Publish/Core/Persistence/Legacy/Notification/Mapper.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\SPI\Persistence\Notification\Notification;
12 use eZ\Publish\SPI\Persistence\Notification\UpdateStruct;
13 use RuntimeException;
14
15 class Mapper
16 {
24 public function extractNotificationsFromRows(array $rows): array
25 {
26 $notifications = [];
27 foreach ($rows as $row) {
28 $notifications[] = $this->extractNotificationFromRow($row);
29 }
30
31 return $notifications;
32 }
33
39 public function createNotificationFromUpdateStruct(UpdateStruct $updateStruct): Notification
40 {
41 $notification = new Notification();
42 $notification->isPending = $updateStruct->isPending;
43
44 return $notification;
45 }
46
54 private function extractNotificationFromRow(array $row): Notification
55 {
56 $notification = new Notification();
57 $notification->id = (int)$row['id'];
58 $notification->ownerId = (int)$row['owner_id'];
59 $notification->type = $row['type'];
60 $notification->created = (int)$row['created'];
61 $notification->isPending = (bool) $row['is_pending'];
62 if ($row['data'] !== null) {
63 $notification->data = json_decode($row['data'], true);
64 if (json_last_error() !== JSON_ERROR_NONE) {
65 throw new RuntimeException('Error while decoding notification data: ' . json_last_error_msg());
66 }
67 }
68
69 return $notification;
70 }
71 }
eZ\Publish\Core\Persistence\Legacy\Notification\Mapper
Definition: Publish/Core/Persistence/Legacy/Notification/Mapper.php:16
eZ\Publish\Core\Persistence\Legacy\Notification\Mapper\extractNotificationFromRow
extractNotificationFromRow(array $row)
Extract Bookmark object from $row.
Definition: Publish/Core/Persistence/Legacy/Notification/Mapper.php:54
eZ\Publish\Core\Persistence\Legacy\Notification\Mapper\extractNotificationsFromRows
extractNotificationsFromRows(array $rows)
Extracts Bookmark objects from $rows.
Definition: Publish/Core/Persistence/Legacy/Notification/Mapper.php:24
eZ\Publish\Core\Persistence\Legacy\Notification\Mapper\createNotificationFromUpdateStruct
createNotificationFromUpdateStruct(UpdateStruct $updateStruct)
Definition: Publish/Core/Persistence/Legacy/Notification/Mapper.php:39
eZ\Publish\SPI\Persistence\Notification\Notification
Definition: SPI/Persistence/Notification/Notification.php:14
eZ\Publish\SPI\Persistence\Notification\UpdateStruct
Definition: Notification/UpdateStruct.php:14
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.