Completed
Push — master ( 0fdc9b...bee941 )
by Łukasz
21:26
created

NotificationService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace eZ\Publish\Core\Repository\SiteAccessAware;
5
6
use eZ\Publish\API\Repository\NotificationService as NotificationServiceInterface;
7
use eZ\Publish\API\Repository\Values\Notification\CreateStruct;
8
use eZ\Publish\API\Repository\Values\Notification\Notification;
9
use eZ\Publish\API\Repository\Values\Notification\NotificationList;
10
11
class NotificationService implements NotificationServiceInterface
12
{
13
    /** @var \eZ\Publish\API\Repository\NotificationService */
14
    protected $service;
15
16
    /**
17
     * Construct service object from aggregated service.
18
     *
19
     * @param \eZ\Publish\API\Repository\NotificationService $service
20
     */
21
    public function __construct(
22
        NotificationServiceInterface $service
23
    ) {
24
        $this->service = $service;
25
    }
26
27
    /**
28
     * Get currently logged user notifications.
29
     *
30
     * @param int $offset
31
     * @param int $limit
32
     *
33
     * @return \eZ\Publish\API\Repository\Values\Notification\NotificationList
34
     */
35
    public function loadNotifications(int $offset, int $limit): NotificationList
36
    {
37
        return $this->service->loadNotifications($offset, $limit);
38
    }
39
40
    /**
41
     * @param int $notificationId
42
     *
43
     * @return \eZ\Publish\API\Repository\Values\Notification\Notification
44
     */
45
    public function getNotification(int $notificationId): Notification
46
    {
47
        return $this->service->getNotification($notificationId);
48
    }
49
50
    /**
51
     * Mark notification as read so it no longer bother the user.
52
     *
53
     * @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
54
     */
55
    public function markNotificationAsRead(Notification $notification): void
56
    {
57
        $this->service->markNotificationAsRead($notification);
58
    }
59
60
    /**
61
     * Get count of unread users notifications.
62
     *
63
     * @return int
64
     */
65
    public function getPendingNotificationCount(): int
66
    {
67
        return $this->service->getPendingNotificationCount();
68
    }
69
70
    /**
71
     * Get count of total users notifications.
72
     *
73
     * @return int
74
     */
75
    public function getNotificationCount(): int
76
    {
77
        return $this->service->getNotificationCount();
78
    }
79
80
    /**
81
     * @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
82
     */
83
    public function deleteNotification(Notification $notification): void
84
    {
85
        $this->service->deleteNotification($notification);
86
    }
87
88
    /**
89
     * @param \eZ\Publish\API\Repository\Values\Notification\CreateStruct $createStruct
90
     *
91
     * @return \eZ\Publish\API\Repository\Values\Notification\Notification
92
     */
93
    public function createNotification(CreateStruct $createStruct): Notification
94
    {
95
        return $this->service->createNotification($createStruct);
96
    }
97
}
98