Completed
Push — 7.5 ( 13f815...467086 )
by André
19:24
created

ContentService::countContentDrafts()   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
    public function loadReverseRelations(ContentInfo $contentInfo)
182
    {
183
        return $this->service->loadReverseRelations($contentInfo);
184
    }
185
186
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
187
    {
188
        return $this->service->addRelation($sourceVersion, $destinationContent);
189
    }
190
191
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
192
    {
193
        return $this->service->deleteRelation($sourceVersion, $destinationContent);
194
    }
195
196
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
197
    {
198
        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...
199
    }
200
201
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
202
    {
203
        return $this->service->deleteTranslation($contentInfo, $languageCode);
204
    }
205
206
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
207
    {
208
        return $this->service->deleteTranslationFromDraft($versionInfo, $languageCode);
209
    }
210
211
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
212
    {
213
        return $this->service->loadContentListByContentInfo($contentInfoList, $languages, $useAlwaysAvailable);
214
    }
215
216
    public function hideContent(ContentInfo $contentInfo): void
217
    {
218
        $this->service->hideContent($contentInfo);
219
    }
220
221
    public function revealContent(ContentInfo $contentInfo): void
222
    {
223
        $this->service->revealContent($contentInfo);
224
    }
225
226
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
227
    {
228
        return $this->service->newContentCreateStruct($contentType, $mainLanguageCode);
229
    }
230
231
    public function newContentMetadataUpdateStruct()
232
    {
233
        return $this->service->newContentMetadataUpdateStruct();
234
    }
235
236
    public function newContentUpdateStruct()
237
    {
238
        return $this->service->newContentUpdateStruct();
239
    }
240
}
241