Completed
Push — EZP-30969-fetch-reverse-relati... ( d71d24...a0ef69 )
by
unknown
137:48 queued 117:08
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
 * File containing the 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\REST\Client;
10
11
use eZ\Publish\API\Repository\ContentService as APIContentService;
12
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
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\TranslationInfo;
19
use eZ\Publish\API\Repository\Values\Content\RelationList;
20
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
21
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
22
use eZ\Publish\API\Repository\Values\Content\Query;
23
use eZ\Publish\API\Repository\Values\User\User;
24
use eZ\Publish\Core\REST\Common\RequestParser;
25
use eZ\Publish\Core\REST\Common\Input\Dispatcher;
26
use eZ\Publish\Core\REST\Common\Output\Visitor;
27
use eZ\Publish\Core\REST\Common\Message;
28
29
/**
30
 * @example Examples/contenttype.php
31
 */
32
class ContentService implements APIContentService, Sessionable
33
{
34
    /** @var \eZ\Publish\Core\REST\Client\HttpClient */
35
    private $client;
36
37
    /** @var \eZ\Publish\Core\REST\Common\Input\Dispatcher */
38
    private $inputDispatcher;
39
40
    /** @var \eZ\Publish\Core\REST\Common\Output\Visitor */
41
    private $outputVisitor;
42
43
    /** @var \eZ\Publish\Core\REST\Common\RequestParser */
44
    private $requestParser;
45
46
    /** @var \eZ\Publish\Core\REST\Client\ContentTypeService */
47
    private $contentTypeService;
48
49
    /**
50
     * @param \eZ\Publish\Core\REST\Client\HttpClient $client
51
     * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher
52
     * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor
53
     * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser
54
     * @param \eZ\Publish\Core\REST\Client\ContentTypeService $contentTypeService
55
     */
56
    public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser, ContentTypeService $contentTypeService)
57
    {
58
        $this->client = $client;
59
        $this->inputDispatcher = $inputDispatcher;
60
        $this->outputVisitor = $outputVisitor;
61
        $this->requestParser = $requestParser;
62
        $this->contentTypeService = $contentTypeService;
63
    }
64
65
    /**
66
     * Set session ID.
67
     *
68
     * Only for testing
69
     *
70
     * @param mixed $id
71
     *
72
     * @private
73
     */
74
    public function setSession($id)
75
    {
76
        if ($this->outputVisitor instanceof Sessionable) {
77
            $this->outputVisitor->setSession($id);
78
        }
79
    }
80
81
    /**
82
     * Loads a content info object.
83
     *
84
     * To load fields use loadContent
85
     *
86
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
87
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist
88
     *
89
     * @param int $contentId
90
     *
91
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
92
     */
93
    public function loadContentInfo($contentId)
94
    {
95
        $response = $this->client->request(
96
            'GET',
97
            $contentId,
98
            new Message(
99
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
100
            )
101
        );
102
103
        $restContentInfo = $this->inputDispatcher->parse($response);
104
105
        return $this->completeContentInfo($restContentInfo);
0 ignored issues
show
Compatibility introduced by
$restContentInfo of type object<eZ\Publish\API\Re...ory\Values\ValueObject> is not a sub-type of object<eZ\Publish\Core\R...Values\RestContentInfo>. It seems like you assume a child class of the class eZ\Publish\API\Repository\Values\ValueObject to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function loadContentInfoList(array $contentIds): iterable
112
    {
113
        throw new \Exception('@todo: Implement.');
114
    }
115
116
    /**
117
     * Loads a content info object for the given remoteId.
118
     *
119
     * To load fields use loadContent
120
     *
121
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
122
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist
123
     *
124
     * @param string $remoteId
125
     *
126
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
127
     */
128
    public function loadContentInfoByRemoteId($remoteId)
129
    {
130
        $response = $this->client->request(
131
            'GET',
132
            $this->requestParser->generate('objectByRemote', array('object' => $remoteId)),
133
            new Message(
134
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
135
            )
136
        );
137
138
        if ($response->statusCode == 307) {
139
            $response = $this->client->request(
140
                'GET',
141
                $response->headers['Location'],
142
                new Message(
143
                    array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
144
                )
145
            );
146
        }
147
148
        $restContentInfo = $this->inputDispatcher->parse($response);
149
150
        return $this->completeContentInfo($restContentInfo);
0 ignored issues
show
Compatibility introduced by
$restContentInfo of type object<eZ\Publish\API\Re...ory\Values\ValueObject> is not a sub-type of object<eZ\Publish\Core\R...Values\RestContentInfo>. It seems like you assume a child class of the class eZ\Publish\API\Repository\Values\ValueObject to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
151
    }
152
153
    /**
154
     * Returns a complete ContentInfo based on $restContentInfo.
155
     *
156
     * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo
157
     *
158
     * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo
159
     */
160
    protected function completeContentInfo(Values\RestContentInfo $restContentInfo)
161
    {
162
        $versionUrlValues = $this->requestParser->parse(
163
            'objectVersion',
164
            $this->fetchCurrentVersionUrl($restContentInfo->currentVersionReference)
165
        );
166
167
        return new Values\Content\ContentInfo(
168
            $this->contentTypeService,
169
            array(
170
                'id' => $restContentInfo->id,
171
                'name' => $restContentInfo->name,
172
                'contentTypeId' => $restContentInfo->contentTypeId,
173
                'ownerId' => $restContentInfo->ownerId,
174
                'modificationDate' => $restContentInfo->modificationDate,
175
                'publishedDate' => $restContentInfo->publishedDate,
176
                'published' => $restContentInfo->published,
177
                'alwaysAvailable' => $restContentInfo->alwaysAvailable,
178
                'remoteId' => $restContentInfo->remoteId,
179
                'mainLanguageCode' => $restContentInfo->mainLanguageCode,
180
                'mainLocationId' => $restContentInfo->mainLocationId,
181
                'sectionId' => $restContentInfo->sectionId,
182
183
                'currentVersionNo' => $versionUrlValues['version'],
184
            )
185
        );
186
    }
187
188
    /**
189
     * Returns the URL of the current version referenced by
190
     * $currentVersionReference.
191
     *
192
     * @param string $currentVersionReference
193
     *
194
     * @return string
195
     */
196
    protected function fetchCurrentVersionUrl($currentVersionReference)
197
    {
198
        $versionResponse = $this->client->request(
199
            'GET',
200
            $currentVersionReference
201
        );
202
203
        if ($this->isErrorResponse($versionResponse)) {
204
            return $this->inputDispatcher->parse($versionResponse);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->inputDispa...arse($versionResponse); (eZ\Publish\API\Repository\Values\ValueObject) is incompatible with the return type documented by eZ\Publish\Core\REST\Cli...:fetchCurrentVersionUrl of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
205
        }
206
207
        return $versionResponse->headers['Location'];
208
    }
209
210
    /**
211
     * Checks if the given response is an error.
212
     *
213
     * @param Message $response
214
     *
215
     * @return bool
216
     */
217
    protected function isErrorResponse(Message $response)
218
    {
219
        return strpos($response->headers['Content-Type'], 'application/vnd.ez.api.ErrorMessage') === 0;
220
    }
221
222
    /**
223
     * Loads a version info of the given content object.
224
     *
225
     * If no version number is given, the method returns the current version
226
     *
227
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
228
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
229
     *
230
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
231
     * @param int $versionNo the version number. If not given the current version is returned.
232
     *
233
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
234
     */
235
    public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)
236
    {
237
        throw new \Exception('@todo: Implement.');
238
    }
239
240
    /**
241
     * Loads a version info of the given content object id.
242
     *
243
     * If no version number is given, the method returns the current version
244
     *
245
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
246
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
247
     *
248
     * @param mixed $contentId
249
     * @param int $versionNo the version number. If not given the current version is returned.
250
     *
251
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
252
     */
253
    public function loadVersionInfoById($contentId, $versionNo = null)
254
    {
255
        throw new \Exception('@todo: Implement.');
256
    }
257
258
    /**
259
     * Loads content in a version for the given content info object.
260
     *
261
     * If no version number is given, the method returns the current version
262
     *
263
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
264
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
265
     *
266
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
267
     * @param array $languages A language filter for fields. If not given all languages are returned
268
     * @param int $versionNo the version number. If not given the current version is returned
269
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
270
     *
271
     * @return \eZ\Publish\API\Repository\Values\Content\Content
272
     */
273
    public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
274
    {
275
        return $this->loadContent(
276
            $contentInfo->id,
277
            $languages,
278
            $versionNo
279
        );
280
    }
281
282
    /**
283
     * Loads content in the version given by version info.
284
     *
285
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
286
     *
287
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
288
     * @param array $languages A language filter for fields. If not given all languages are returned
289
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
290
     *
291
     * @return \eZ\Publish\API\Repository\Values\Content\Content
292
     */
293
    public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true)
294
    {
295
        $contentInfo = $versionInfo->getContentInfo();
296
297
        return $this->loadContent($contentInfo->id, $languages, $versionInfo->versionNo);
298
    }
299
300
    /**
301
     * Loads content in a version of the given content object.
302
     *
303
     * If no version number is given, the method returns the current version
304
     *
305
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist
306
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
307
     *
308
     * @param int $contentId
309
     * @param array $languages A language filter for fields. If not given all languages are returned
310
     * @param int $versionNo the version number. If not given the current version is returned
311
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
312
     *
313
     * @return \eZ\Publish\API\Repository\Values\Content\Content
314
     *
315
     * @todo Handle $versionNo = null
316
     * @todo Handle language filters
317
     */
318
    public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
319
    {
320
        // $contentId should already be a URL!
321
        $contentIdValues = $this->requestParser->parse('object', $contentId);
322
323
        $url = '';
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
324
        if ($versionNo === null) {
325
            $url = $this->fetchCurrentVersionUrl(
326
                $this->requestParser->generate(
327
                    'objectCurrentVersion',
328
                    array(
329
                        'object' => $contentIdValues['object'],
330
                    )
331
                )
332
            );
333
        } else {
334
            $url = $this->requestParser->generate(
335
                'objectVersion',
336
                array(
337
                    'object' => $contentIdValues['object'],
338
                    'version' => $versionNo,
339
                )
340
            );
341
        }
342
343
        $response = $this->client->request(
344
            'GET',
345
            $url,
346
            new Message(
347
                array('Accept' => $this->outputVisitor->getMediaType('Version'))
348
            )
349
        );
350
351
        return $this->inputDispatcher->parse($response);
352
    }
353
354
    /**
355
     * Loads content in a version for the content object reference by the given remote id.
356
     *
357
     * If no version is given, the method returns the current version
358
     *
359
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist
360
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
361
     *
362
     * @param string $remoteId
363
     * @param array $languages A language filter for fields. If not given all languages are returned
364
     * @param int $versionNo the version number. If not given the current version is returned
365
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
366
     *
367
     * @return \eZ\Publish\API\Repository\Values\Content\Content
368
     */
369
    public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
370
    {
371
        $contentInfo = $this->loadContentInfoByRemoteId($remoteId);
372
373
        return $this->loadContentByContentInfo($contentInfo, $languages, $versionNo);
374
    }
375
376
    /**
377
     * Creates a new content draft assigned to the authenticated user.
378
     *
379
     * If a different userId is given in $contentCreateStruct it is assigned to the given user
380
     * but this required special rights for the authenticated user
381
     * (this is useful for content staging where the transfer process does not
382
     * have to authenticate with the user which created the content object in the source server).
383
     * The user has to publish the draft if it should be visible.
384
     * In 4.x at least one location has to be provided in the location creation array.
385
     *
386
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
387
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system
388
     *                                                                        or there is no location provided (4.x) or multiple locations
389
     *                                                                        are under the same parent or if the a field value is not accepted by the field type
390
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid
391
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing
392
     *
393
     * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct
394
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content
395
     *
396
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
397
     */
398
    public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array())
399
    {
400
        throw new \Exception('@todo: Implement.');
401
    }
402
403
    /**
404
     * Updates the metadata.
405
     *
406
     * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent
407
     *
408
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data
409
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists
410
     *
411
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
412
     * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct
413
     *
414
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes
415
     */
416
    public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)
417
    {
418
        throw new \Exception('@todo: Implement.');
419
    }
420
421
    /**
422
     * Deletes a content object including all its versions and locations including their subtrees.
423
     *
424
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete the content (in one of the locations of the given content object)
425
     *
426
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
427
     */
428
    public function deleteContent(ContentInfo $contentInfo)
429
    {
430
        throw new \Exception('@todo: Implement.');
431
    }
432
433
    /**
434
     * Creates a draft from a published or archived version.
435
     *
436
     * If no version is given, the current published version is used.
437
     * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.
438
     * It can be changed on updating the version.
439
     *
440
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft
441
     *
442
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
443
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
444
     * @param \eZ\Publish\API\Repository\Values\User\User $user if set given user is used to create the draft - otherwise the current user is used
445
     *
446
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
447
     */
448
    public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null)
449
    {
450
        throw new \Exception('@todo: Implement.');
451
    }
452
453
    /**
454
     * Loads drafts for a user.
455
     *
456
     * If no user is given the drafts for the authenticated user a returned
457
     *
458
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list
459
     *
460
     * @param \eZ\Publish\API\Repository\Values\User\User $user
461
     *
462
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user
463
     */
464
    public function loadContentDrafts(User $user = null)
465
    {
466
        throw new \Exception('@todo: Implement.');
467
    }
468
469
    /**
470
     * Updates the fields of a draft.
471
     *
472
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
473
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
474
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid
475
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
476
     *
477
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
478
     * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct
479
     *
480
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields
481
     */
482
    public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct)
483
    {
484
        throw new \Exception('@todo: Implement.');
485
    }
486
487
    /**
488
     * Publishes a content version.
489
     *
490
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
491
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
492
     *
493
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
494
     * @param string[] $translations
495
     *
496
     * @return \eZ\Publish\API\Repository\Values\Content\Content
497
     *
498
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
499
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
500
     */
501
    public function publishVersion(VersionInfo $versionInfo, array $translations = Language::ALL)
502
    {
503
        throw new \Exception('@todo: Implement.');
504
    }
505
506
    /**
507
     * Removes the given version.
508
     *
509
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
510
     *         published state or is a last version of the Content
511
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
512
     *
513
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
514
     */
515
    public function deleteVersion(VersionInfo $versionInfo)
516
    {
517
        throw new \Exception('@todo: Implement.');
518
    }
519
520
    /**
521
     * Loads all versions for the given content.
522
     *
523
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
524
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the given status is invalid
525
     *
526
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
527
     * @param int|null $status
528
     *
529
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date
530
     */
531
    public function loadVersions(ContentInfo $contentInfo, ?int $status = null)
532
    {
533
        throw new \Exception('@todo: Implement.');
534
    }
535
536
    /**
537
     * Copies the content to a new location. If no version is given,
538
     * all versions are copied, otherwise only the given version.
539
     *
540
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
541
     *
542
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
543
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
544
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
545
     *
546
     * @return \eZ\Publish\API\Repository\Values\Content\Content
547
     */
548
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
549
    {
550
        throw new \Exception('@todo: Implement.');
551
    }
552
553
    /**
554
     * Finds content objects for the given query.
555
     *
556
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
557
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
558
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
559
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
560
     *
561
     * @return \eZ\Publish\API\Repository\Values\Content\SearchResult
562
     */
563
    public function findContent(Query $query, array $languageFilter, $filterOnUserPermissions = true)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $languageFilter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filterOnUserPermissions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
564
    {
565
        throw new \Exception('@todo: Implement.');
566
    }
567
568
    /**
569
     * Performs a query for a single content object.
570
     *
571
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions
572
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result
573
     *
574
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
575
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
576
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
577
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
578
     *
579
     * @return \eZ\Publish\API\Repository\Values\Content\Content
580
     */
581
    public function findSingle(Query $query, array $languageFilter, $filterOnUserPermissions = true)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $languageFilter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filterOnUserPermissions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
582
    {
583
        throw new \Exception('@todo: Implement.');
584
    }
585
586
    /**
587
     * Loads all outgoing relations for the given version.
588
     *
589
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
590
     *
591
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
592
     *
593
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
594
     */
595
    public function loadRelations(VersionInfo $versionInfo)
596
    {
597
        throw new \Exception('@todo: Implement.');
598
    }
599
600
    /**
601
     * Loads all incoming relations for a content object.
602
     *
603
     * The relations come only
604
     * from published versions of the source content objects
605
     *
606
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
607
     *
608
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
609
     *
610
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
611
     */
612
    public function loadReverseRelations(ContentInfo $contentInfo)
613
    {
614
        throw new \Exception('@todo: Implement.');
615
    }
616
617
    /**
618
     * {@inheritdoc}
619
     */
620
    public function loadReverseRelationList(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList
621
    {
622
        throw new \Exception('@todo: Implement.');
623
    }
624
625
    /**
626
     * Adds a relation of type common.
627
     *
628
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
629
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
630
     *
631
     * The source of the relation is the content and version
632
     * referenced by $versionInfo.
633
     *
634
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
635
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
636
     *
637
     * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation
638
     */
639
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
640
    {
641
        throw new \Exception('@todo: Implement.');
642
    }
643
644
    /**
645
     * Removes a relation of type COMMON from a draft.
646
     *
647
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
648
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
649
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
650
     *
651
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
652
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
653
     */
654
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
655
    {
656
        throw new \Exception('@todo: Implement.');
657
    }
658
659
    /**
660
     * Instantiates a new content create struct object.
661
     *
662
     * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
663
     *
664
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
665
     * @param string $mainLanguageCode
666
     *
667
     * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
668
     */
669
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
670
    {
671
        throw new \Exception('@todo: Implement.');
672
    }
673
674
    /**
675
     * Instantiates a new content meta data update struct.
676
     *
677
     * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
678
     */
679
    public function newContentMetadataUpdateStruct()
680
    {
681
        throw new \Exception('@todo: Implement.');
682
    }
683
684
    /**
685
     * Instantiates a new content update struct.
686
     *
687
     * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
688
     */
689
    public function newContentUpdateStruct()
690
    {
691
        throw new \Exception('@todo: Implement.');
692
    }
693
694
    // Ignore this eZ Publish 5 feature by now.
695
696
    // @codeCoverageIgnoreStart
697
698
    /**
699
     * {@inheritdoc}
700
     */
701
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
702
    {
703
        throw new \Exception('@todo: Implement.');
704
    }
705
706
    /**
707
     * {@inheritdoc}
708
     */
709
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
710
    {
711
        throw new \Exception('@todo: Implement.');
712
    }
713
714
    /**
715
     * {@inheritdoc}
716
     */
717
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
718
    {
719
        throw new \Exception('@todo: Implement.');
720
    }
721
722
    /**
723
     * Bulk-load Content items by the list of ContentInfo Value Objects.
724
     *
725
     * Note: it does not throw exceptions on load, just ignores erroneous Content item.
726
     *
727
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList
728
     * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
729
     *                            returned value object. If not given all languages are returned.
730
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,
731
     *                                 unless all languages have been asked for.
732
     *
733
     * @throws \Exception Not implemented
734
     */
735
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
736
    {
737
        throw new \Exception('@todo: Implement.');
738
    }
739
740
    /**
741
     * Hides Content by making all the Locations appear hidden.
742
     * It does not persist hidden state on Location object itself.
743
     *
744
     * Content hidden by this API can be revealed by revealContent API.
745
     *
746
     * @see revealContent
747
     *
748
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
749
     */
750
    public function hideContent(ContentInfo $contentInfo): void
751
    {
752
        throw new \Exception('@todo: Implement.');
753
    }
754
755
    /**
756
     * Reveals Content hidden by hideContent API.
757
     * Locations which were hidden before hiding Content will remain hidden.
758
     *
759
     * @see hideContent
760
     *
761
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
762
     */
763
    public function revealContent(ContentInfo $contentInfo): void
764
    {
765
        throw new \Exception('@todo: Implement.');
766
    }
767
}
768