Skip to content

Commit

Permalink
EZP-29340: Added NotificationService as a part of SiteAccessAware Rep…
Browse files Browse the repository at this point in the history
…ository layer (ezsystems#2363)
  • Loading branch information
Nattfarinn authored and Łukasz Serwatka committed Jun 27, 2018
1 parent 0fdc9b3 commit bee941a
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
97 changes: 97 additions & 0 deletions eZ/Publish/Core/Repository/SiteAccessAware/NotificationService.php
@@ -0,0 +1,97 @@
<?php
declare(strict_types=1);

namespace eZ\Publish\Core\Repository\SiteAccessAware;

use eZ\Publish\API\Repository\NotificationService as NotificationServiceInterface;
use eZ\Publish\API\Repository\Values\Notification\CreateStruct;
use eZ\Publish\API\Repository\Values\Notification\Notification;
use eZ\Publish\API\Repository\Values\Notification\NotificationList;

class NotificationService implements NotificationServiceInterface
{
/** @var \eZ\Publish\API\Repository\NotificationService */
protected $service;

/**
* Construct service object from aggregated service.
*
* @param \eZ\Publish\API\Repository\NotificationService $service
*/
public function __construct(
NotificationServiceInterface $service
) {
$this->service = $service;
}

/**
* Get currently logged user notifications.
*
* @param int $offset
* @param int $limit
*
* @return \eZ\Publish\API\Repository\Values\Notification\NotificationList
*/
public function loadNotifications(int $offset, int $limit): NotificationList
{
return $this->service->loadNotifications($offset, $limit);
}

/**
* @param int $notificationId
*
* @return \eZ\Publish\API\Repository\Values\Notification\Notification
*/
public function getNotification(int $notificationId): Notification
{
return $this->service->getNotification($notificationId);
}

/**
* Mark notification as read so it no longer bother the user.
*
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
*/
public function markNotificationAsRead(Notification $notification): void
{
$this->service->markNotificationAsRead($notification);
}

/**
* Get count of unread users notifications.
*
* @return int
*/
public function getPendingNotificationCount(): int
{
return $this->service->getPendingNotificationCount();
}

/**
* Get count of total users notifications.
*
* @return int
*/
public function getNotificationCount(): int
{
return $this->service->getNotificationCount();
}

/**
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
*/
public function deleteNotification(Notification $notification): void
{
$this->service->deleteNotification($notification);
}

/**
* @param \eZ\Publish\API\Repository\Values\Notification\CreateStruct $createStruct
*
* @return \eZ\Publish\API\Repository\Values\Notification\Notification
*/
public function createNotification(CreateStruct $createStruct): Notification
{
return $this->service->createNotification($createStruct);
}
}
12 changes: 11 additions & 1 deletion eZ/Publish/Core/Repository/SiteAccessAware/Repository.php
Expand Up @@ -51,6 +51,9 @@ class Repository implements RepositoryInterface
/** @var \eZ\Publish\API\Repository\URLAliasService */
protected $urlAliasService;

/** @var \eZ\Publish\Core\Repository\NotificationService */
protected $notificationService;

/**
* Construct repository object from aggregated repository.
*/
Expand All @@ -65,7 +68,8 @@ public function __construct(
SectionService $sectionService,
TrashService $trashService,
LocationService $locationService,
LanguageService $languageService
LanguageService $languageService,
NotificationService $notificationService
) {
$this->repository = $repository;
$this->contentService = $contentService;
Expand All @@ -78,6 +82,7 @@ public function __construct(
$this->trashService = $trashService;
$this->locationService = $locationService;
$this->languageService = $languageService;
$this->notificationService = $notificationService;
}

public function getCurrentUser()
Expand Down Expand Up @@ -190,6 +195,11 @@ public function getBookmarkService()
return $this->repository->getBookmarkService();
}

public function getNotificationService()
{
return $this->repository->getNotificationService();
}

public function beginTransaction()
{
return $this->repository->beginTransaction();
Expand Down
6 changes: 6 additions & 0 deletions eZ/Publish/Core/settings/repository/siteaccessaware.yml
Expand Up @@ -13,6 +13,7 @@ services:
- '@ezpublish.siteaccessaware.service.trash'
- '@ezpublish.siteaccessaware.service.location'
- '@ezpublish.siteaccessaware.service.language'
- '@ezpublish.siteaccessaware.service.notification'


ezpublish.siteaccessaware.service.content:
Expand Down Expand Up @@ -73,6 +74,11 @@ services:
arguments:
- '@ezpublish.signalslot.service.language'

ezpublish.siteaccessaware.service.notification:
class: eZ\Publish\Core\Repository\SiteAccessAware\NotificationService
arguments:
- '@eZ\Publish\Core\SignalSlot\NotificationService'

# Helpers
ezpublish.helper.language_resolver:
class: eZ\Publish\Core\Repository\SiteAccessAware\Language\LanguageResolver
Expand Down

0 comments on commit bee941a

Please sign in to comment.