Completed
Push — ezp-30616 ( 9239a0...7bf8e8 )
by
unknown
57:53 queued 37:56
created

URLService::loadById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
namespace eZ\Publish\Core\SignalSlot;
8
9
use eZ\Publish\API\Repository\URLService as URLServiceInterface;
10
use eZ\Publish\API\Repository\Values\URL\URL;
11
use eZ\Publish\API\Repository\Values\URL\URLQuery;
12
use eZ\Publish\API\Repository\Values\URL\URLUpdateStruct;
13
use eZ\Publish\Core\SignalSlot\Signal\URLService\UpdateUrlSignal;
14
15
class URLService implements URLServiceInterface
16
{
17
    /**
18
     * Aggregated service.
19
     *
20
     * @var \eZ\Publish\API\Repository\URLService
21
     */
22
    protected $service;
23
24
    /**
25
     * SignalDispatcher.
26
     *
27
     * @var SignalDispatcher
28
     */
29
    protected $signalDispatcher;
30
31
    /**
32
     * URLService constructor.
33
     *
34
     * @param \eZ\Publish\API\Repository\URLService $service
35
     * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
36
     */
37
    public function __construct(URLServiceInterface $service, SignalDispatcher $signalDispatcher)
38
    {
39
        $this->service = $service;
40
        $this->signalDispatcher = $signalDispatcher;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function createUpdateStruct()
47
    {
48
        return $this->service->createUpdateStruct();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function findUrls(URLQuery $query)
55
    {
56
        return $this->service->findUrls($query);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function findUsages(URL $url, $offset = 0, $limit = -1)
63
    {
64
        return $this->service->findUsages($url, $offset, $limit);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function loadById($id)
71
    {
72
        return $this->service->loadById($id);
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function loadByUrl($url)
79
    {
80
        return $this->service->loadByUrl($url);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function updateUrl(URL $url, URLUpdateStruct $struct)
87
    {
88
        $returnValue = $this->service->updateUrl($url, $struct);
89
90
        $this->signalDispatcher->emit(
91
            new UpdateUrlSignal([
92
                'urlId' => $returnValue->id,
93
                'urlChanged' => $struct->url !== null,
94
            ])
95
        );
96
97
        return $returnValue;
98
    }
99
}
100