Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/master'
  • Loading branch information
brookinsconsulting committed Jun 27, 2018
2 parents 1eca84d + ac1af80 commit 72e19cb
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Notification/Renderer/NotificationRenderer.php
@@ -0,0 +1,28 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Notification\Renderer;

use eZ\Publish\API\Repository\Values\Notification\Notification;

interface NotificationRenderer
{
/**
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
*
* @return string
*/
public function render(Notification $notification): string;

/**
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
*
* @return string|null
*/
public function generateUrl(Notification $notification): ?string;
}
7 changes: 7 additions & 0 deletions Persistence/Handler.php
Expand Up @@ -8,6 +8,8 @@

namespace eZ\Publish\SPI\Persistence;

use eZ\Publish\SPI\Persistence\Notification\Handler as NotificationHandler;

/**
* The main handler for Storage Engine.
*/
Expand Down Expand Up @@ -73,6 +75,11 @@ public function urlHandler();
*/
public function bookmarkHandler();

/**
* @return \eZ\Publish\SPI\Persistence\Notification\Handler
*/
public function notificationHandler();

/**
* @return \eZ\Publish\SPI\Persistence\TransactionHandler
*/
Expand Down
29 changes: 29 additions & 0 deletions Persistence/Notification/CreateStruct.php
@@ -0,0 +1,29 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Persistence\Notification;

use eZ\Publish\SPI\Persistence\ValueObject;

class CreateStruct extends ValueObject
{
/** @var int $ownerId */
public $ownerId;

/** @var string $type */
public $type;

/** @var bool $isPending */
public $isPending;

/** @var array $data */
public $data = [];

/** @var int $created */
public $created;
}
73 changes: 73 additions & 0 deletions Persistence/Notification/Handler.php
@@ -0,0 +1,73 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Persistence\Notification;

use eZ\Publish\API\Repository\Values\Notification\Notification as APINotification;

interface Handler
{
/**
* Store Notification ValueObject in persistent storage.
*
* @param \eZ\Publish\SPI\Persistence\Notification\CreateStruct $createStruct
*
* @return \eZ\Publish\SPI\Persistence\Notification\Notification
*/
public function createNotification(CreateStruct $createStruct): Notification;

/**
* Update Notification ValueObject in persistent storage.
* There's no edit feature but it's essential to mark Notification as read.
*
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
* @param \eZ\Publish\SPI\Persistence\Notification\UpdateStruct $updateStruct
*
* @return \eZ\Publish\SPI\Persistence\Notification\Notification
*/
public function updateNotification(APINotification $notification, UpdateStruct $updateStruct): Notification;

/**
* Count users unread Notifications.
*
* @param int $ownerId
*
* @return int
*/
public function countPendingNotifications(int $ownerId): int;

/**
* Get Notification by its id.
*
* @param int $notificationId
*
* @return \eZ\Publish\SPI\Persistence\Notification\Notification
*/
public function getNotificationById(int $notificationId): Notification;

/**
* @param int $userId
* @param int $offset
* @param int $limit
*
* @return \eZ\Publish\SPI\Persistence\Notification\Notification[]
*/
public function loadUserNotifications(int $userId, int $offset, int $limit): array;

/**
* @param int $currentUserId
*
* @return int
*/
public function countNotifications(int $currentUserId): int;

/**
* @param \eZ\Publish\API\Repository\Values\Notification\Notification $notification
*/
public function delete(APINotification $notification): void;
}
32 changes: 32 additions & 0 deletions Persistence/Notification/Notification.php
@@ -0,0 +1,32 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Persistence\Notification;

use eZ\Publish\SPI\Persistence\ValueObject;

class Notification extends ValueObject
{
/** @var int $id */
public $id;

/** @var int $ownerId */
public $ownerId;

/** @var bool $isPending */
public $isPending;

/** @var string $type */
public $type;

/** @var int $created */
public $created;

/** @var array $data */
public $data = [];
}
17 changes: 17 additions & 0 deletions Persistence/Notification/UpdateStruct.php
@@ -0,0 +1,17 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Persistence\Notification;

use eZ\Publish\SPI\Persistence\ValueObject;

class UpdateStruct extends ValueObject
{
/** @var bool $isPending */
public $isPending;
}
1 change: 1 addition & 0 deletions Tests/FieldType/BaseIntegrationTest.php
Expand Up @@ -574,6 +574,7 @@ protected function getContainer()
$loader->load('repository.yml');
$loader->load('repository/inner.yml');
$loader->load('repository/signalslot.yml');
$loader->load('repository/siteaccessaware.yml');
$loader->load('fieldtype_external_storages.yml');
$loader->load('storage_engines/common.yml');
$loader->load('storage_engines/shortcuts.yml');
Expand Down
1 change: 1 addition & 0 deletions Tests/FieldType/FileBaseIntegrationTest.php
Expand Up @@ -137,6 +137,7 @@ protected function getContainer()
$loader->load('repository.yml');
$loader->load('repository/inner.yml');
$loader->load('repository/signalslot.yml');
$loader->load('repository/siteaccessaware.yml');
$loader->load('fieldtype_external_storages.yml');
$loader->load('storage_engines/common.yml');
$loader->load('storage_engines/shortcuts.yml');
Expand Down

0 comments on commit 72e19cb

Please sign in to comment.