Completed
Push — master ( 0b3034...a98e2b )
by
unknown
36:06 queued 14:31
created

ContentService::deleteRelation()   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 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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\LocationCreateStruct;
17
use eZ\Publish\API\Repository\Values\Content\TranslationInfo;
18
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
19
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
20
use eZ\Publish\API\Repository\Values\Content\Query;
21
use eZ\Publish\API\Repository\Values\User\User;
22
use eZ\Publish\Core\REST\Common\RequestParser;
23
use eZ\Publish\Core\REST\Common\Input\Dispatcher;
24
use eZ\Publish\Core\REST\Common\Output\Visitor;
25
use eZ\Publish\Core\REST\Common\Message;
26
27
/**
28
 * @example Examples/contenttype.php
29
 */
30
class ContentService implements APIContentService, Sessionable
31
{
32
    /**
33
     * @var \eZ\Publish\Core\REST\Client\HttpClient
34
     */
35
    private $client;
36
37
    /**
38
     * @var \eZ\Publish\Core\REST\Common\Input\Dispatcher
39
     */
40
    private $inputDispatcher;
41
42
    /**
43
     * @var \eZ\Publish\Core\REST\Common\Output\Visitor
44
     */
45
    private $outputVisitor;
46
47
    /**
48
     * @var \eZ\Publish\Core\REST\Common\RequestParser
49
     */
50
    private $requestParser;
51
52
    /**
53
     * @var \eZ\Publish\Core\REST\Client\ContentTypeService
54
     */
55
    private $contentTypeService;
56
57
    /**
58
     * @param \eZ\Publish\Core\REST\Client\HttpClient $client
59
     * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher
60
     * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor
61
     * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser
62
     * @param \eZ\Publish\Core\REST\Client\ContentTypeService $contentTypeService
63
     */
64 View Code Duplication
    public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser, ContentTypeService $contentTypeService)
65
    {
66
        $this->client = $client;
67
        $this->inputDispatcher = $inputDispatcher;
68
        $this->outputVisitor = $outputVisitor;
69
        $this->requestParser = $requestParser;
70
        $this->contentTypeService = $contentTypeService;
71
    }
72
73
    /**
74
     * Set session ID.
75
     *
76
     * Only for testing
77
     *
78
     * @param mixed $id
79
     *
80
     * @private
81
     */
82
    public function setSession($id)
83
    {
84
        if ($this->outputVisitor instanceof Sessionable) {
85
            $this->outputVisitor->setSession($id);
86
        }
87
    }
88
89
    /**
90
     * Loads a content info object.
91
     *
92
     * To load fields use loadContent
93
     *
94
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
95
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist
96
     *
97
     * @param int $contentId
98
     *
99
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
100
     */
101
    public function loadContentInfo($contentId)
102
    {
103
        $response = $this->client->request(
104
            'GET',
105
            $contentId,
106
            new Message(
107
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
108
            )
109
        );
110
111
        $restContentInfo = $this->inputDispatcher->parse($response);
112
113
        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...
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 View Code Duplication
    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
     *
495
     * @return \eZ\Publish\API\Repository\Values\Content\Content
496
     *
497
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
498
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
499
     */
500
    public function publishVersion(VersionInfo $versionInfo)
501
    {
502
        throw new \Exception('@todo: Implement.');
503
    }
504
505
    /**
506
     * Removes the given version.
507
     *
508
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
509
     *         published state or is a last version of the Content
510
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
511
     *
512
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
513
     */
514
    public function deleteVersion(VersionInfo $versionInfo)
515
    {
516
        throw new \Exception('@todo: Implement.');
517
    }
518
519
    /**
520
     * Loads all versions for the given content.
521
     *
522
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
523
     *
524
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
525
     *
526
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date
527
     */
528
    public function loadVersions(ContentInfo $contentInfo)
529
    {
530
        throw new \Exception('@todo: Implement.');
531
    }
532
533
    /**
534
     * Copies the content to a new location. If no version is given,
535
     * all versions are copied, otherwise only the given version.
536
     *
537
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
538
     *
539
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
540
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
541
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
542
     *
543
     * @return \eZ\Publish\API\Repository\Values\Content\Content
544
     */
545
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
546
    {
547
        throw new \Exception('@todo: Implement.');
548
    }
549
550
    /**
551
     * Finds content objects for the given query.
552
     *
553
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
554
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
555
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
556
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
557
     *
558
     * @return \eZ\Publish\API\Repository\Values\Content\SearchResult
559
     */
560
    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...
561
    {
562
        throw new \Exception('@todo: Implement.');
563
    }
564
565
    /**
566
     * Performs a query for a single content object.
567
     *
568
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions
569
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result
570
     *
571
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
572
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
573
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
574
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
575
     *
576
     * @return \eZ\Publish\API\Repository\Values\Content\Content
577
     */
578
    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...
579
    {
580
        throw new \Exception('@todo: Implement.');
581
    }
582
583
    /**
584
     * Loads all outgoing relations for the given version.
585
     *
586
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
587
     *
588
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
589
     *
590
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
591
     */
592
    public function loadRelations(VersionInfo $versionInfo)
593
    {
594
        throw new \Exception('@todo: Implement.');
595
    }
596
597
    /**
598
     * Loads all incoming relations for a content object.
599
     *
600
     * The relations come only
601
     * from published versions of the source content objects
602
     *
603
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
604
     *
605
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
606
     *
607
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
608
     */
609
    public function loadReverseRelations(ContentInfo $contentInfo)
610
    {
611
        throw new \Exception('@todo: Implement.');
612
    }
613
614
    /**
615
     * Adds a relation of type common.
616
     *
617
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
618
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
619
     *
620
     * The source of the relation is the content and version
621
     * referenced by $versionInfo.
622
     *
623
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
624
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
625
     *
626
     * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation
627
     */
628
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
629
    {
630
        throw new \Exception('@todo: Implement.');
631
    }
632
633
    /**
634
     * Removes a relation of type COMMON from a draft.
635
     *
636
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
637
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
638
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
639
     *
640
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
641
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
642
     */
643
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
644
    {
645
        throw new \Exception('@todo: Implement.');
646
    }
647
648
    /**
649
     * Instantiates a new content create struct object.
650
     *
651
     * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
652
     *
653
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
654
     * @param string $mainLanguageCode
655
     *
656
     * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
657
     */
658
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
659
    {
660
        throw new \Exception('@todo: Implement.');
661
    }
662
663
    /**
664
     * Instantiates a new content meta data update struct.
665
     *
666
     * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
667
     */
668
    public function newContentMetadataUpdateStruct()
669
    {
670
        throw new \Exception('@todo: Implement.');
671
    }
672
673
    /**
674
     * Instantiates a new content update struct.
675
     *
676
     * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
677
     */
678
    public function newContentUpdateStruct()
679
    {
680
        throw new \Exception('@todo: Implement.');
681
    }
682
683
    // Ignore this eZ Publish 5 feature by now.
684
685
    // @codeCoverageIgnoreStart
686
687
    /**
688
     * {@inheritdoc}
689
     */
690
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
691
    {
692
        throw new \Exception('@todo: Implement.');
693
    }
694
695
    /**
696
     * {@inheritdoc}
697
     */
698
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
699
    {
700
        throw new \Exception('@todo: Implement.');
701
    }
702
703
    /**
704
     * {@inheritdoc}
705
     */
706
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
707
    {
708
        throw new \Exception('@todo: Implement.');
709
    }
710
711
    /**
712
     * Bulk-load Content items by the list of ContentInfo Value Objects.
713
     *
714
     * Note: it does not throw exceptions on load, just ignores erroneous Content item.
715
     *
716
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList
717
     * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
718
     *                            returned value object. If not given all languages are returned.
719
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,
720
     *                                 unless all languages have been asked for.
721
     *
722
     * @throws \Exception Not implemented
723
     */
724
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
725
    {
726
        throw new \Exception('@todo: Implement.');
727
    }
728
729
    /**
730
     * Instantiates a new TranslationInfo object.
731
     *
732
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo
733
     */
734
    public function newTranslationInfo()
735
    {
736
        throw new \Exception('@todo: Implement.');
737
    }
738
739
    /**
740
     * Instantiates a Translation object.
741
     *
742
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues
743
     */
744
    public function newTranslationValues()
745
    {
746
        throw new \Exception('@todo: Implement.');
747
    }
748
}
749