Completed
Push — master ( 336c64...8fa798 )
by Łukasz
25:31
created

BookmarkService::loadBookmarks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
rs 10
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\SignalSlot;
10
11
use eZ\Publish\API\Repository\BookmarkService as BookmarkServiceInterface;
12
use eZ\Publish\API\Repository\Values\Bookmark\BookmarkList;
13
use eZ\Publish\API\Repository\Values\Content\Location;
14
use eZ\Publish\Core\SignalSlot\Signal\BookmarkService\CreateBookmarkSignal;
15
use eZ\Publish\Core\SignalSlot\Signal\BookmarkService\DeleteBookmarkSignal;
16
17
class BookmarkService implements BookmarkServiceInterface
18
{
19
    /**
20
     * Aggregated service.
21
     *
22
     * @var \eZ\Publish\API\Repository\BookmarkService
23
     */
24
    protected $service;
25
26
    /**
27
     * SignalDispatcher.
28
     *
29
     * @var \eZ\Publish\Core\SignalSlot\SignalDispatcher
30
     */
31
    protected $signalDispatcher;
32
33
    /**
34
     * BookmarkService constructor.
35
     *
36
     * @param \eZ\Publish\API\Repository\BookmarkService $service
37
     * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
38
     */
39
    public function __construct(BookmarkServiceInterface $service, SignalDispatcher $signalDispatcher)
40
    {
41
        $this->service = $service;
42
        $this->signalDispatcher = $signalDispatcher;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function createBookmark(Location $location): void
49
    {
50
        $this->service->createBookmark($location);
51
52
        $this->signalDispatcher->emit(new CreateBookmarkSignal([
53
            'locationId' => $location->id,
54
        ]));
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function deleteBookmark(Location $location): void
61
    {
62
        $this->service->deleteBookmark($location);
63
64
        $this->signalDispatcher->emit(new DeleteBookmarkSignal([
65
            'locationId' => $location->id,
66
        ]));
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function loadBookmarks(int $offset = 0, int $limit = 25): BookmarkList
73
    {
74
        return $this->service->loadBookmarks($offset, $limit);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function isBookmarked(Location $location): bool
81
    {
82
        return $this->service->isBookmarked($location);
83
    }
84
}
85