Completed
Push — 7.5 ( 467086...6987e3 )
by Łukasz
19:03
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\ContentType\ContentType;
19
use eZ\Publish\API\Repository\Values\User\User;
20
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
21
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
22
use eZ\Publish\API\Repository\LanguageResolver;
23
24
/**
25
 * SiteAccess aware implementation of ContentService injecting languages where needed.
26
 */
27
class ContentService implements ContentServiceInterface
28
{
29
    /** @var \eZ\Publish\API\Repository\ContentService */
30
    protected $service;
31
32
    /** @var \eZ\Publish\API\Repository\LanguageResolver */
33
    protected $languageResolver;
34
35
    /**
36
     * Construct service object from aggregated service and LanguageResolver.
37
     *
38
     * @param \eZ\Publish\API\Repository\ContentService $service
39
     * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
40
     */
41
    public function __construct(
42
        ContentServiceInterface $service,
43
        LanguageResolver $languageResolver
44
    ) {
45
        $this->service = $service;
46
        $this->languageResolver = $languageResolver;
47
    }
48
49
    public function loadContentInfo($contentId)
50
    {
51
        return $this->service->loadContentInfo($contentId);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function loadContentInfoList(array $contentIds): iterable
58
    {
59
        return $this->service->loadContentInfoList($contentIds);
60
    }
61
62
    public function loadContentInfoByRemoteId($remoteId)
63
    {
64
        return $this->service->loadContentInfoByRemoteId($remoteId);
65
    }
66
67
    public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)
68
    {
69
        return $this->service->loadVersionInfo($contentInfo, $versionNo);
70
    }
71
72
    public function loadVersionInfoById($contentId, $versionNo = null)
73
    {
74
        return $this->service->loadVersionInfoById($contentId, $versionNo);
75
    }
76
77
    public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
78
    {
79
        return $this->service->loadContentByContentInfo(
80
            $contentInfo,
81
            $this->languageResolver->getPrioritizedLanguages($languages),
82
            $versionNo,
83
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
84
        );
85
    }
86
87
    public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = null)
88
    {
89
        return $this->service->loadContentByVersionInfo(
90
            $versionInfo,
91
            $this->languageResolver->getPrioritizedLanguages($languages),
92
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
93
        );
94
    }
95
96
    public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
97
    {
98
        return $this->service->loadContent(
99
            $contentId,
100
            $this->languageResolver->getPrioritizedLanguages($languages),
101
            $versionNo,
102
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
103
        );
104
    }
105
106
    public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = null)
107
    {
108
        return $this->service->loadContentByRemoteId(
109
            $remoteId,
110
            $this->languageResolver->getPrioritizedLanguages($languages),
111
            $versionNo,
112
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
113
        );
114
    }
115
116
    public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = [])
117
    {
118
        return $this->service->createContent($contentCreateStruct, $locationCreateStructs);
119
    }
120
121
    public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)
122
    {
123
        return $this->service->updateContentMetadata($contentInfo, $contentMetadataUpdateStruct);
124
    }
125
126
    public function deleteContent(ContentInfo $contentInfo)
127
    {
128
        return $this->service->deleteContent($contentInfo);
129
    }
130
131
    public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null)
132
    {
133
        return $this->service->createContentDraft($contentInfo, $versionInfo, $user);
134
    }
135
136
    public function countContentDrafts(?User $user = null): int
137
    {
138
        return $this->service->countContentDrafts($user);
139
    }
140
141
    public function loadContentDrafts(User $user = null)
142
    {
143
        return $this->service->loadContentDrafts($user);
144
    }
145
146
    public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList
147
    {
148
        return $this->service->loadContentDraftList($user, $offset, $limit);
149
    }
150
151
    public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct)
152
    {
153
        return $this->service->updateContent($versionInfo, $contentUpdateStruct);
154
    }
155
156
    public function publishVersion(VersionInfo $versionInfo, array $translations = Language::ALL)
157
    {
158
        return $this->service->publishVersion($versionInfo, $translations);
159
    }
160
161
    public function deleteVersion(VersionInfo $versionInfo)
162
    {
163
        return $this->service->deleteVersion($versionInfo);
164
    }
165
166
    public function loadVersions(ContentInfo $contentInfo, ?int $status = null)
167
    {
168
        return $this->service->loadVersions($contentInfo, $status);
169
    }
170
171
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
172
    {
173
        return $this->service->copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo);
174
    }
175
176
    public function loadRelations(VersionInfo $versionInfo)
177
    {
178
        return $this->service->loadRelations($versionInfo);
179
    }
180
181
    /**
182
     * {@inheritdoc}
183
     */
184
    public function countReverseRelations(ContentInfo $contentInfo): int
185
    {
186
        return $this->service->countReverseRelations($contentInfo);
187
    }
188
189
    public function loadReverseRelations(ContentInfo $contentInfo)
190
    {
191
        return $this->service->loadReverseRelations($contentInfo);
192
    }
193
194
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
195
    {
196
        return $this->service->addRelation($sourceVersion, $destinationContent);
197
    }
198
199
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
200
    {
201
        return $this->service->deleteRelation($sourceVersion, $destinationContent);
202
    }
203
204
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
205
    {
206
        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...
207
    }
208
209
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
210
    {
211
        return $this->service->deleteTranslation($contentInfo, $languageCode);
212
    }
213
214
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
215
    {
216
        return $this->service->deleteTranslationFromDraft($versionInfo, $languageCode);
217
    }
218
219
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
220
    {
221
        return $this->service->loadContentListByContentInfo($contentInfoList, $languages, $useAlwaysAvailable);
222
    }
223
224
    public function hideContent(ContentInfo $contentInfo): void
225
    {
226
        $this->service->hideContent($contentInfo);
227
    }
228
229
    public function revealContent(ContentInfo $contentInfo): void
230
    {
231
        $this->service->revealContent($contentInfo);
232
    }
233
234
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
235
    {
236
        return $this->service->newContentCreateStruct($contentType, $mainLanguageCode);
237
    }
238
239
    public function newContentMetadataUpdateStruct()
240
    {
241
        return $this->service->newContentMetadataUpdateStruct();
242
    }
243
244
    public function newContentUpdateStruct()
245
    {
246
        return $this->service->newContentUpdateStruct();
247
    }
248
}
249