Completed
Push — EZP-30969-fetch-reverse-relati... ( f9e12d...5e1246 )
by
unknown
18:37
created

ContentService::countReverseRelations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
nc 1
nop 1
rs 10
1
<?php
2
3
/**
4
 * ContentService class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Repository\SiteAccessAware;
10
11
use eZ\Publish\API\Repository\ContentService as ContentServiceInterface;
12
use eZ\Publish\API\Repository\Values\Content\ContentDraftList;
13
use eZ\Publish\API\Repository\Values\Content\ContentCreateStruct;
14
use eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct;
15
use eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct;
16
use eZ\Publish\API\Repository\Values\Content\Language;
17
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
18
use eZ\Publish\API\Repository\Values\Content\RelationList;
19
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
20
use eZ\Publish\API\Repository\Values\User\User;
21
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
22
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
23
use eZ\Publish\API\Repository\LanguageResolver;
24
25
/**
26
 * SiteAccess aware implementation of ContentService injecting languages where needed.
27
 */
28
class ContentService implements ContentServiceInterface
29
{
30
    /** @var \eZ\Publish\API\Repository\ContentService */
31
    protected $service;
32
33
    /** @var \eZ\Publish\API\Repository\LanguageResolver */
34
    protected $languageResolver;
35
36
    /**
37
     * Construct service object from aggregated service and LanguageResolver.
38
     *
39
     * @param \eZ\Publish\API\Repository\ContentService $service
40
     * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
41
     */
42
    public function __construct(
43
        ContentServiceInterface $service,
44
        LanguageResolver $languageResolver
45
    ) {
46
        $this->service = $service;
47
        $this->languageResolver = $languageResolver;
48
    }
49
50
    public function loadContentInfo($contentId)
51
    {
52
        return $this->service->loadContentInfo($contentId);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function loadContentInfoList(array $contentIds): iterable
59
    {
60
        return $this->service->loadContentInfoList($contentIds);
61
    }
62
63
    public function loadContentInfoByRemoteId($remoteId)
64
    {
65
        return $this->service->loadContentInfoByRemoteId($remoteId);
66
    }
67
68
    public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)
69
    {
70
        return $this->service->loadVersionInfo($contentInfo, $versionNo);
71
    }
72
73
    public function loadVersionInfoById($contentId, $versionNo = null)
74
    {
75
        return $this->service->loadVersionInfoById($contentId, $versionNo);
76
    }
77
78
    public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
79
    {
80
        return $this->service->loadContentByContentInfo(
81
            $contentInfo,
82
            $this->languageResolver->getPrioritizedLanguages($languages),
83
            $versionNo,
84
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
85
        );
86
    }
87
88
    public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = null)
89
    {
90
        return $this->service->loadContentByVersionInfo(
91
            $versionInfo,
92
            $this->languageResolver->getPrioritizedLanguages($languages),
93
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
94
        );
95
    }
96
97
    public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
98
    {
99
        return $this->service->loadContent(
100
            $contentId,
101
            $this->languageResolver->getPrioritizedLanguages($languages),
102
            $versionNo,
103
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
104
        );
105
    }
106
107
    public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
108
    {
109
        return $this->service->loadContentByRemoteId(
110
            $remoteId,
111
            $this->languageResolver->getPrioritizedLanguages($languages),
112
            $versionNo,
113
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
114
        );
115
    }
116
117
    public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = [])
118
    {
119
        return $this->service->createContent($contentCreateStruct, $locationCreateStructs);
120
    }
121
122
    public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)
123
    {
124
        return $this->service->updateContentMetadata($contentInfo, $contentMetadataUpdateStruct);
125
    }
126
127
    public function deleteContent(ContentInfo $contentInfo)
128
    {
129
        return $this->service->deleteContent($contentInfo);
130
    }
131
132
    public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null)
133
    {
134
        return $this->service->createContentDraft($contentInfo, $versionInfo, $user);
135
    }
136
137
    public function countContentDrafts(?User $user = null): int
138
    {
139
        return $this->service->countContentDrafts($user);
140
    }
141
142
    public function loadContentDrafts(User $user = null)
143
    {
144
        return $this->service->loadContentDrafts($user);
145
    }
146
147
    public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList
148
    {
149
        return $this->service->loadContentDraftList($user, $offset, $limit);
150
    }
151
152
    public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct)
153
    {
154
        return $this->service->updateContent($versionInfo, $contentUpdateStruct);
155
    }
156
157
    public function publishVersion(VersionInfo $versionInfo, array $translations = Language::ALL)
158
    {
159
        return $this->service->publishVersion($versionInfo, $translations);
160
    }
161
162
    public function deleteVersion(VersionInfo $versionInfo)
163
    {
164
        return $this->service->deleteVersion($versionInfo);
165
    }
166
167
    public function loadVersions(ContentInfo $contentInfo, ?int $status = null)
168
    {
169
        return $this->service->loadVersions($contentInfo, $status);
170
    }
171
172
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
173
    {
174
        return $this->service->copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo);
175
    }
176
177
    public function loadRelations(VersionInfo $versionInfo)
178
    {
179
        return $this->service->loadRelations($versionInfo);
180
    }
181
182
    /**
183
     * {@inheritdoc}
184
     */
185
    public function countReverseRelations(ContentInfo $contentInfo): int
186
    {
187
        return $this->service->countReverseRelations($contentInfo);
188
    }
189
190
    public function loadReverseRelations(ContentInfo $contentInfo)
191
    {
192
        return $this->service->loadReverseRelations($contentInfo);
193
    }
194
195
    public function loadReverseRelationList(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList
196
    {
197
        return $this->service->loadReverseRelationList($contentInfo, $offset, $limit);
198
    }
199
200
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
201
    {
202
        return $this->service->addRelation($sourceVersion, $destinationContent);
203
    }
204
205
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
206
    {
207
        return $this->service->deleteRelation($sourceVersion, $destinationContent);
208
    }
209
210
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
211
    {
212
        return $this->service->removeTranslation($contentInfo, $languageCode);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...ce::removeTranslation() has been deprecated with message: since 6.13, use {@see deleteTranslation} instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
213
    }
214
215
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
216
    {
217
        return $this->service->deleteTranslation($contentInfo, $languageCode);
218
    }
219
220
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
221
    {
222
        return $this->service->deleteTranslationFromDraft($versionInfo, $languageCode);
223
    }
224
225
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
226
    {
227
        return $this->service->loadContentListByContentInfo($contentInfoList, $languages, $useAlwaysAvailable);
228
    }
229
230
    public function hideContent(ContentInfo $contentInfo): void
231
    {
232
        $this->service->hideContent($contentInfo);
233
    }
234
235
    public function revealContent(ContentInfo $contentInfo): void
236
    {
237
        $this->service->revealContent($contentInfo);
238
    }
239
240
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
241
    {
242
        return $this->service->newContentCreateStruct($contentType, $mainLanguageCode);
243
    }
244
245
    public function newContentMetadataUpdateStruct()
246
    {
247
        return $this->service->newContentMetadataUpdateStruct();
248
    }
249
250
    public function newContentUpdateStruct()
251
    {
252
        return $this->service->newContentUpdateStruct();
253
    }
254
}
255