Completed
Push — master ( 6c3e1a...f2dfe9 )
by André
17:55
created

ContentService::newContentMetadataUpdateStruct()   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 0
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
     * {@inheritdoc}
118
     */
119
    public function loadContentInfoList(array $contentIds): iterable
120
    {
121
        throw new \Exception('@todo: Implement.');
122
    }
123
124
    /**
125
     * Loads a content info object for the given remoteId.
126
     *
127
     * To load fields use loadContent
128
     *
129
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
130
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist
131
     *
132
     * @param string $remoteId
133
     *
134
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
135
     */
136 View Code Duplication
    public function loadContentInfoByRemoteId($remoteId)
137
    {
138
        $response = $this->client->request(
139
            'GET',
140
            $this->requestParser->generate('objectByRemote', array('object' => $remoteId)),
141
            new Message(
142
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
143
            )
144
        );
145
146
        if ($response->statusCode == 307) {
147
            $response = $this->client->request(
148
                'GET',
149
                $response->headers['Location'],
150
                new Message(
151
                    array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
152
                )
153
            );
154
        }
155
156
        $restContentInfo = $this->inputDispatcher->parse($response);
157
158
        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...
159
    }
160
161
    /**
162
     * Returns a complete ContentInfo based on $restContentInfo.
163
     *
164
     * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo
165
     *
166
     * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo
167
     */
168
    protected function completeContentInfo(Values\RestContentInfo $restContentInfo)
169
    {
170
        $versionUrlValues = $this->requestParser->parse(
171
            'objectVersion',
172
            $this->fetchCurrentVersionUrl($restContentInfo->currentVersionReference)
173
        );
174
175
        return new Values\Content\ContentInfo(
176
            $this->contentTypeService,
177
            array(
178
                'id' => $restContentInfo->id,
179
                'name' => $restContentInfo->name,
180
                'contentTypeId' => $restContentInfo->contentTypeId,
181
                'ownerId' => $restContentInfo->ownerId,
182
                'modificationDate' => $restContentInfo->modificationDate,
183
                'publishedDate' => $restContentInfo->publishedDate,
184
                'published' => $restContentInfo->published,
185
                'alwaysAvailable' => $restContentInfo->alwaysAvailable,
186
                'remoteId' => $restContentInfo->remoteId,
187
                'mainLanguageCode' => $restContentInfo->mainLanguageCode,
188
                'mainLocationId' => $restContentInfo->mainLocationId,
189
                'sectionId' => $restContentInfo->sectionId,
190
191
                'currentVersionNo' => $versionUrlValues['version'],
192
            )
193
        );
194
    }
195
196
    /**
197
     * Returns the URL of the current version referenced by
198
     * $currentVersionReference.
199
     *
200
     * @param string $currentVersionReference
201
     *
202
     * @return string
203
     */
204
    protected function fetchCurrentVersionUrl($currentVersionReference)
205
    {
206
        $versionResponse = $this->client->request(
207
            'GET',
208
            $currentVersionReference
209
        );
210
211
        if ($this->isErrorResponse($versionResponse)) {
212
            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...
213
        }
214
215
        return $versionResponse->headers['Location'];
216
    }
217
218
    /**
219
     * Checks if the given response is an error.
220
     *
221
     * @param Message $response
222
     *
223
     * @return bool
224
     */
225
    protected function isErrorResponse(Message $response)
226
    {
227
        return strpos($response->headers['Content-Type'], 'application/vnd.ez.api.ErrorMessage') === 0;
228
    }
229
230
    /**
231
     * Loads a version info of the given content object.
232
     *
233
     * If no version number is given, the method returns the current version
234
     *
235
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
236
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
237
     *
238
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
239
     * @param int $versionNo the version number. If not given the current version is returned.
240
     *
241
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
242
     */
243
    public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)
244
    {
245
        throw new \Exception('@todo: Implement.');
246
    }
247
248
    /**
249
     * Loads a version info of the given content object id.
250
     *
251
     * If no version number is given, the method returns the current version
252
     *
253
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
254
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
255
     *
256
     * @param mixed $contentId
257
     * @param int $versionNo the version number. If not given the current version is returned.
258
     *
259
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
260
     */
261
    public function loadVersionInfoById($contentId, $versionNo = null)
262
    {
263
        throw new \Exception('@todo: Implement.');
264
    }
265
266
    /**
267
     * Loads content in a version for the given content info object.
268
     *
269
     * If no version number is given, the method returns the current version
270
     *
271
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
272
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
273
     *
274
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
275
     * @param array $languages A language filter for fields. If not given all languages are returned
276
     * @param int $versionNo the version number. If not given the current version is returned
277
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
278
     *
279
     * @return \eZ\Publish\API\Repository\Values\Content\Content
280
     */
281
    public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
282
    {
283
        return $this->loadContent(
284
            $contentInfo->id,
285
            $languages,
286
            $versionNo
287
        );
288
    }
289
290
    /**
291
     * Loads content in the version given by version info.
292
     *
293
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
294
     *
295
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
296
     * @param array $languages A language filter for fields. If not given all languages are returned
297
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
298
     *
299
     * @return \eZ\Publish\API\Repository\Values\Content\Content
300
     */
301
    public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true)
302
    {
303
        $contentInfo = $versionInfo->getContentInfo();
304
305
        return $this->loadContent($contentInfo->id, $languages, $versionInfo->versionNo);
306
    }
307
308
    /**
309
     * Loads content in a version of the given content object.
310
     *
311
     * If no version number is given, the method returns the current version
312
     *
313
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist
314
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
315
     *
316
     * @param int $contentId
317
     * @param array $languages A language filter for fields. If not given all languages are returned
318
     * @param int $versionNo the version number. If not given the current version is returned
319
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
320
     *
321
     * @return \eZ\Publish\API\Repository\Values\Content\Content
322
     *
323
     * @todo Handle $versionNo = null
324
     * @todo Handle language filters
325
     */
326
    public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
327
    {
328
        // $contentId should already be a URL!
329
        $contentIdValues = $this->requestParser->parse('object', $contentId);
330
331
        $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...
332
        if ($versionNo === null) {
333
            $url = $this->fetchCurrentVersionUrl(
334
                $this->requestParser->generate(
335
                    'objectCurrentVersion',
336
                    array(
337
                        'object' => $contentIdValues['object'],
338
                    )
339
                )
340
            );
341
        } else {
342
            $url = $this->requestParser->generate(
343
                'objectVersion',
344
                array(
345
                    'object' => $contentIdValues['object'],
346
                    'version' => $versionNo,
347
                )
348
            );
349
        }
350
351
        $response = $this->client->request(
352
            'GET',
353
            $url,
354
            new Message(
355
                array('Accept' => $this->outputVisitor->getMediaType('Version'))
356
            )
357
        );
358
359
        return $this->inputDispatcher->parse($response);
360
    }
361
362
    /**
363
     * Loads content in a version for the content object reference by the given remote id.
364
     *
365
     * If no version is given, the method returns the current version
366
     *
367
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist
368
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
369
     *
370
     * @param string $remoteId
371
     * @param array $languages A language filter for fields. If not given all languages are returned
372
     * @param int $versionNo the version number. If not given the current version is returned
373
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
374
     *
375
     * @return \eZ\Publish\API\Repository\Values\Content\Content
376
     */
377
    public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
378
    {
379
        $contentInfo = $this->loadContentInfoByRemoteId($remoteId);
380
381
        return $this->loadContentByContentInfo($contentInfo, $languages, $versionNo);
382
    }
383
384
    /**
385
     * Creates a new content draft assigned to the authenticated user.
386
     *
387
     * If a different userId is given in $contentCreateStruct it is assigned to the given user
388
     * but this required special rights for the authenticated user
389
     * (this is useful for content staging where the transfer process does not
390
     * have to authenticate with the user which created the content object in the source server).
391
     * The user has to publish the draft if it should be visible.
392
     * In 4.x at least one location has to be provided in the location creation array.
393
     *
394
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
395
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system
396
     *                                                                        or there is no location provided (4.x) or multiple locations
397
     *                                                                        are under the same parent or if the a field value is not accepted by the field type
398
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid
399
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing
400
     *
401
     * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct
402
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content
403
     *
404
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
405
     */
406
    public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array())
407
    {
408
        throw new \Exception('@todo: Implement.');
409
    }
410
411
    /**
412
     * Updates the metadata.
413
     *
414
     * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent
415
     *
416
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data
417
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists
418
     *
419
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
420
     * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct
421
     *
422
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes
423
     */
424
    public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)
425
    {
426
        throw new \Exception('@todo: Implement.');
427
    }
428
429
    /**
430
     * Deletes a content object including all its versions and locations including their subtrees.
431
     *
432
     * @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)
433
     *
434
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
435
     */
436
    public function deleteContent(ContentInfo $contentInfo)
437
    {
438
        throw new \Exception('@todo: Implement.');
439
    }
440
441
    /**
442
     * Creates a draft from a published or archived version.
443
     *
444
     * If no version is given, the current published version is used.
445
     * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.
446
     * It can be changed on updating the version.
447
     *
448
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft
449
     *
450
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
451
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
452
     * @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
453
     *
454
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
455
     */
456
    public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null)
457
    {
458
        throw new \Exception('@todo: Implement.');
459
    }
460
461
    /**
462
     * Loads drafts for a user.
463
     *
464
     * If no user is given the drafts for the authenticated user a returned
465
     *
466
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list
467
     *
468
     * @param \eZ\Publish\API\Repository\Values\User\User $user
469
     *
470
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user
471
     */
472
    public function loadContentDrafts(User $user = null)
473
    {
474
        throw new \Exception('@todo: Implement.');
475
    }
476
477
    /**
478
     * Updates the fields of a draft.
479
     *
480
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
481
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
482
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid
483
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
484
     *
485
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
486
     * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct
487
     *
488
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields
489
     */
490
    public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct)
491
    {
492
        throw new \Exception('@todo: Implement.');
493
    }
494
495
    /**
496
     * Publishes a content version.
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
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
502
     *
503
     * @return \eZ\Publish\API\Repository\Values\Content\Content
504
     *
505
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
506
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
507
     */
508
    public function publishVersion(VersionInfo $versionInfo)
509
    {
510
        throw new \Exception('@todo: Implement.');
511
    }
512
513
    /**
514
     * Removes the given version.
515
     *
516
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
517
     *         published state or is a last version of the Content
518
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
519
     *
520
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
521
     */
522
    public function deleteVersion(VersionInfo $versionInfo)
523
    {
524
        throw new \Exception('@todo: Implement.');
525
    }
526
527
    /**
528
     * Loads all versions for the given content.
529
     *
530
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
531
     *
532
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
533
     *
534
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date
535
     */
536
    public function loadVersions(ContentInfo $contentInfo)
537
    {
538
        throw new \Exception('@todo: Implement.');
539
    }
540
541
    /**
542
     * Copies the content to a new location. If no version is given,
543
     * all versions are copied, otherwise only the given version.
544
     *
545
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
546
     *
547
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
548
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
549
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
550
     *
551
     * @return \eZ\Publish\API\Repository\Values\Content\Content
552
     */
553
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
554
    {
555
        throw new \Exception('@todo: Implement.');
556
    }
557
558
    /**
559
     * Finds content objects for the given query.
560
     *
561
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
562
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
563
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
564
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
565
     *
566
     * @return \eZ\Publish\API\Repository\Values\Content\SearchResult
567
     */
568
    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...
569
    {
570
        throw new \Exception('@todo: Implement.');
571
    }
572
573
    /**
574
     * Performs a query for a single content object.
575
     *
576
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions
577
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result
578
     *
579
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
580
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
581
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
582
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
583
     *
584
     * @return \eZ\Publish\API\Repository\Values\Content\Content
585
     */
586
    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...
587
    {
588
        throw new \Exception('@todo: Implement.');
589
    }
590
591
    /**
592
     * Loads all outgoing relations for the given version.
593
     *
594
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
595
     *
596
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
597
     *
598
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
599
     */
600
    public function loadRelations(VersionInfo $versionInfo)
601
    {
602
        throw new \Exception('@todo: Implement.');
603
    }
604
605
    /**
606
     * Loads all incoming relations for a content object.
607
     *
608
     * The relations come only
609
     * from published versions of the source content objects
610
     *
611
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
612
     *
613
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
614
     *
615
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
616
     */
617
    public function loadReverseRelations(ContentInfo $contentInfo)
618
    {
619
        throw new \Exception('@todo: Implement.');
620
    }
621
622
    /**
623
     * Adds a relation of type common.
624
     *
625
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
626
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
627
     *
628
     * The source of the relation is the content and version
629
     * referenced by $versionInfo.
630
     *
631
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
632
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
633
     *
634
     * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation
635
     */
636
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
637
    {
638
        throw new \Exception('@todo: Implement.');
639
    }
640
641
    /**
642
     * Removes a relation of type COMMON from a draft.
643
     *
644
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
645
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
646
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
647
     *
648
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
649
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
650
     */
651
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
652
    {
653
        throw new \Exception('@todo: Implement.');
654
    }
655
656
    /**
657
     * Instantiates a new content create struct object.
658
     *
659
     * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
660
     *
661
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
662
     * @param string $mainLanguageCode
663
     *
664
     * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
665
     */
666
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
667
    {
668
        throw new \Exception('@todo: Implement.');
669
    }
670
671
    /**
672
     * Instantiates a new content meta data update struct.
673
     *
674
     * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
675
     */
676
    public function newContentMetadataUpdateStruct()
677
    {
678
        throw new \Exception('@todo: Implement.');
679
    }
680
681
    /**
682
     * Instantiates a new content update struct.
683
     *
684
     * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
685
     */
686
    public function newContentUpdateStruct()
687
    {
688
        throw new \Exception('@todo: Implement.');
689
    }
690
691
    // Ignore this eZ Publish 5 feature by now.
692
693
    // @codeCoverageIgnoreStart
694
695
    /**
696
     * {@inheritdoc}
697
     */
698
    public function removeTranslation(ContentInfo $contentInfo, $languageCode)
699
    {
700
        throw new \Exception('@todo: Implement.');
701
    }
702
703
    /**
704
     * {@inheritdoc}
705
     */
706
    public function deleteTranslation(ContentInfo $contentInfo, $languageCode)
707
    {
708
        throw new \Exception('@todo: Implement.');
709
    }
710
711
    /**
712
     * {@inheritdoc}
713
     */
714
    public function deleteTranslationFromDraft(VersionInfo $versionInfo, $languageCode)
715
    {
716
        throw new \Exception('@todo: Implement.');
717
    }
718
719
    /**
720
     * Bulk-load Content items by the list of ContentInfo Value Objects.
721
     *
722
     * Note: it does not throw exceptions on load, just ignores erroneous Content item.
723
     *
724
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo[] $contentInfoList
725
     * @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
726
     *                            returned value object. If not given all languages are returned.
727
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,
728
     *                                 unless all languages have been asked for.
729
     *
730
     * @throws \Exception Not implemented
731
     */
732
    public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], $useAlwaysAvailable = true)
733
    {
734
        throw new \Exception('@todo: Implement.');
735
    }
736
737
    /**
738
     * Instantiates a new TranslationInfo object.
739
     *
740
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo
741
     */
742
    public function newTranslationInfo()
743
    {
744
        throw new \Exception('@todo: Implement.');
745
    }
746
747
    /**
748
     * Instantiates a Translation object.
749
     *
750
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues
751
     */
752
    public function newTranslationValues()
753
    {
754
        throw new \Exception('@todo: Implement.');
755
    }
756
}
757