/
ContentService.php
621 lines (575 loc) · 33 KB
/
ContentService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Contracts\Core\Repository;
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentDraftList;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentList;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentMetadataUpdateStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\Language;
use Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct;
use Ibexa\Contracts\Core\Repository\Values\Content\Relation;
use Ibexa\Contracts\Core\Repository\Values\Content\RelationList;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\Repository\Values\Filter\Filter;
use Ibexa\Contracts\Core\Repository\Values\User\User;
use Ibexa\Contracts\Core\Repository\Values\ValueObject;
/**
* This class provides service methods for managing content.
*/
interface ContentService
{
public const DEFAULT_PAGE_SIZE = 25;
/**
* Loads a content info object.
*
* To load fields use loadContent
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if the content with the given id does not exist
*
* @param int $contentId
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo
*/
public function loadContentInfo(int $contentId): ContentInfo;
/**
* Bulk-load ContentInfo items by id's.
*
* Note: It does not throw exceptions on load, just skips erroneous (NotFound or Unauthorized) ContentInfo items.
*
* @param int[] $contentIds
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo[] list of ContentInfo with Content Ids as keys
*/
public function loadContentInfoList(array $contentIds): iterable;
/**
* Loads a content info object for the given remoteId.
*
* To load fields use loadContent
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist
*
* @param string $remoteId
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo
*/
public function loadContentInfoByRemoteId(string $remoteId): ContentInfo;
/**
* Loads a version info of the given content object.
*
* If no version number is given, the method returns the current version
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param int|null $versionNo the version number. If not given the current version is returned.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo
*/
public function loadVersionInfo(ContentInfo $contentInfo, ?int $versionNo = null): VersionInfo;
/**
* Loads a version info of the given content object id.
*
* If no version number is given, the method returns the current version
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param int $contentId
* @param int|null $versionNo the version number. If not given the current version is returned.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo
*/
public function loadVersionInfoById(int $contentId, ?int $versionNo = null): VersionInfo;
/**
* Bulk-load VersionInfo items by the list of ContentInfo Value Objects.
*
* @param array<\Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo> $contentInfoList
*
* @return array<int, \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo> List of VersionInfo items with Content Ids as keys
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
*/
public function loadVersionInfoListByContentInfo(array $contentInfoList): array;
/**
* Loads content in a version for the given content info object.
*
* If no version number is given, the method returns the current version
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if version with the given number does not exist
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param array $languages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param int|null $versionNo the version number. If not given the current version is returned from $contentInfo
* @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true): Content;
/**
* Loads content in the version given by version info.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo
* @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, bool $useAlwaysAvailable = true): Content;
/**
* Loads content in a version of the given content object.
*
* If no version number is given, the method returns the current version
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions
*
* @param mixed $contentId
* @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param int|null $versionNo the version number. If not given the current version is returned
* @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function loadContent(int $contentId, array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true): Content;
/**
* Loads content in a version for the content object reference by the given remote id.
*
* If no version is given, the method returns the current version
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException If the user has no access to read content and in case of un-published content: read versions
*
* @param string $remoteId
* @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param int|null $versionNo the version number. If not given the current version is returned
* @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function loadContentByRemoteId(string $remoteId, array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true): Content;
/**
* Bulk-load Content items by the list of ContentInfo Value Objects.
*
* Note: it does not throw exceptions on load, just ignores erroneous Content item.
* Moreover, since the method works on pre-loaded ContentInfo list, it is assumed that user is
* allowed to access every Content on the list.
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo[] $contentInfoList
* @param string[] $languages A language priority, filters returned fields and is used as prioritized language code on
* returned value object. If not given all languages are returned.
* @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true,
* unless all languages have been asked for.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content[] list of Content items with Content Ids as keys
*/
public function loadContentListByContentInfo(array $contentInfoList, array $languages = [], bool $useAlwaysAvailable = true): iterable;
/**
* Creates a new content draft assigned to the authenticated user.
*
* If a different userId is given in $contentCreateStruct it is assigned to the given user
* but this required special rights for the authenticated user
* (this is useful for content staging where the transfer process does not
* have to authenticate with the user which created the content object in the source server).
* The user has to publish the draft if it should be visible.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if there is a provided remote ID which exists in the system or multiple Locations
* are under the same parent or if the a field value is not accepted by the field type
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException if a required field is missing or is set to an empty value
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct $contentCreateStruct
* @param \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs an array of {@link \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct} for each location parent under which a location should be created for the content
* While optional, it's highly recommended to use Locations for content as a lot of features in the system is usually tied to the tree structure (including default Role policies).
* @param string[]|null $fieldIdentifiersToValidate List of field identifiers for partial validation or null
* for case of full validation. Empty identifiers array is equal to no validation.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content - the newly created content draft
*/
public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = [], ?array $fieldIdentifiersToValidate = null): Content;
/**
* Updates the metadata.
*
* (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content the content with the updated attributes
*/
public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct): Content;
/**
* Deletes a content object including all its versions and locations including their subtrees.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete the content (in one of the locations of the given content object)
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
*
* @return int[] Affected Location Id's (List of Locations of the Content that was deleted)
*/
public function deleteContent(ContentInfo $contentInfo): iterable;
/**
* Creates a draft from a published or archived version.
*
* If no version is given, the current published version is used.
* 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.
* It can be changed on updating the version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to create the draft
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo|null $versionInfo
* @param \Ibexa\Contracts\Core\Repository\Values\User\User|null $creator Used as creator of the draft if given - otherwise uses current-user
* @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null if not set the draft is created with the initialLanguage code of the source version or if not present with the main language.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content - the newly created content draft
*/
public function createContentDraft(
ContentInfo $contentInfo,
?VersionInfo $versionInfo = null,
?User $creator = null,
?Language $language = null
): Content;
/**
* Counts drafts for a user.
*
* If no user is given the number of drafts for the authenticated user are returned
*
* @param \Ibexa\Contracts\Core\Repository\Values\User\User $user The user to load drafts for, if defined, otherwise drafts for current-user
*
* @return int The number of drafts ({@link VersionInfo}) owned by the given user
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
public function countContentDrafts(?User $user = null): int;
/**
* Loads drafts for a user.
*
* If no user is given the drafts for the authenticated user are returned
*
* @deprecated Please use {@see ContentService::loadContentDraftList()} instead to avoid risking loading too much data.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to load the draft list
*
* @param \Ibexa\Contracts\Core\Repository\Values\User\User $user The user to load drafts for, if defined, otherwise drafts for current-user
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo[] the drafts ({@link VersionInfo}) owned by the given user
*/
public function loadContentDrafts(?User $user = null): iterable;
/**
* Loads drafts for a user when content is not in the trash. The list is sorted by modification date.
*
* If no user is given the drafts for the authenticated user are returned
*
* @since 7.5.5
*
* @param \Ibexa\Contracts\Core\Repository\Values\User\User|null $user The user to load drafts for, if defined, otherwise drafts for current-user
* @param int $offset
* @param int $limit
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentDraftList
*/
public function loadContentDraftList(?User $user = null, int $offset = 0, int $limit = -1): ContentDraftList;
/**
* Updates the fields of a draft.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the version is not a draft
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if a field value is not accepted by the field type
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct
* @param string[]|null $fieldIdentifiersToValidate List of field identifiers for partial validation or null
* for case of full validation. Empty identifiers array is equal to no validation.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content the content draft with the updated fields
*/
public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct, ?array $fieldIdentifiersToValidate = null): Content;
/**
* Publishes a content version.
*
* Publishes a content version and deletes archive versions if they overflow max archive versions.
* Max archive versions are currently a configuration for default max limit, by default set to 5.
*
* @todo Introduce null|int ContentType->versionArchiveLimit to be able to let admins override this per type.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the version is not a draft
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo
* @param string[] $translations List of language codes of translations which will be included
* in a published version.
* By default all translations from the current version will be published.
* If the list is provided but does not cover all currently published translations,
* the missing ones will be copied from the currently published version,
* overriding those in the current version.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function publishVersion(VersionInfo $versionInfo, array $translations = Language::ALL): Content;
/**
* Removes the given version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the version is in
* published state or is a last version of Content in non draft state
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo
*/
public function deleteVersion(VersionInfo $versionInfo): void;
/**
* Loads all versions for the given content.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if the given status is invalid
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param int|null $status
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo[] an array of {@link \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo} sorted by creation date
*/
public function loadVersions(ContentInfo $contentInfo, ?int $status = null): iterable;
/**
* Copies the content to a new location. If no version is given,
* all versions are copied, otherwise only the given version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content
*/
public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, ?VersionInfo $versionInfo = null): Content;
/**
* Loads all outgoing relations for the given version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
*
* @deprecated 4.5.7 The "ContentService::loadRelations()" method is deprecated, will be removed in 5.0.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Relation[]
*/
public function loadRelations(VersionInfo $versionInfo): iterable;
/**
* Loads all outgoing relations for the given version.
*
* If the user is not allowed to read specific version then a returned `RelationList` will contain `UnauthorizedRelationListItem`
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
*
* @see \Ibexa\Contracts\Core\Repository\Values\Content\RelationList\Item\UnauthorizedRelationListItem
*/
public function loadRelationList(
VersionInfo $versionInfo,
int $offset = 0,
int $limit = self::DEFAULT_PAGE_SIZE
): RelationList;
/**
* Counts all outgoing relations for the given version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
*/
public function countRelations(VersionInfo $versionInfo): int;
/**
* Counts all incoming relations for the given content object.
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
*
* @return int The number of reverse relations ({@link Relation})
*/
public function countReverseRelations(ContentInfo $contentInfo): int;
/**
* Loads all incoming relations for a content object.
*
* The relations come only from published versions of the source content objects
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Relation[]
*/
public function loadReverseRelations(ContentInfo $contentInfo): iterable;
/**
* Loads all incoming relations for a content object.
*
* The relations come only from published versions of the source content objects.
* If the user is not allowed to read specific version then UnauthorizedRelationListItem is returned
* {@link \Ibexa\Contracts\Core\Repository\Values\Content\RelationList\Item\UnauthorizedRelationListItem}
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param int $offset
* @param int $limit
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\RelationList
*/
public function loadReverseRelationList(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList;
/**
* Adds a relation of type common.
*
* The source of the relation is the content and version
* referenced by $versionInfo.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the version is not a draft
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $sourceVersion
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Relation the newly created relation
*/
public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent): Relation;
/**
* Removes a relation of type COMMON from a draft.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the version is not a draft
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $sourceVersion
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $destinationContent
*/
public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent): void;
/**
* Delete Content item Translation from all Versions (including archived ones) of a Content Object.
*
* NOTE: this operation is risky and permanent, so user interface should provide a warning before performing it.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the specified Translation
* is the Main Translation of a Content Item.
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed
* to delete the content (in one of the locations of the given Content Item).
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if languageCode argument
* is invalid for the given content.
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
* @param string $languageCode
*
* @since 6.13
*/
public function deleteTranslation(ContentInfo $contentInfo, string $languageCode): void;
/**
* Delete specified Translation from a Content Draft.
*
* When using together with ContentService::publishVersion() method, make sure to not provide deleted translation
* in translations array, as it is going to be copied again from published version.
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException if the specified Translation
* is the only one the Content Draft has or it is the main Translation of a Content Object.
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException if the user is not allowed
* to edit the Content (in one of the locations of the given Content Object).
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException if languageCode argument
* is invalid for the given Draft.
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException if specified Version was not found
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo Content Version Draft
* @param string $languageCode Language code of the Translation to be removed
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\Content Content Draft w/o the specified Translation
*
* @since 6.12
*/
public function deleteTranslationFromDraft(VersionInfo $versionInfo, string $languageCode): Content;
/**
* Hides Content by making all the Locations appear hidden.
* It does not persist hidden state on Location object itself.
*
* Content hidden by this API can be revealed by revealContent API.
*
* @see ContentService::revealContent()
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
*/
public function hideContent(ContentInfo $contentInfo): void;
/**
* Reveals Content hidden by hideContent API.
* Locations which were hidden before hiding Content will remain hidden.
*
* @see ContentService::hideContent()
*
* @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
*/
public function revealContent(ContentInfo $contentInfo): void;
/**
* Instantiates a new content create struct object.
*
* alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
*
* @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType
* @param string $mainLanguageCode
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct
*/
public function newContentCreateStruct(ContentType $contentType, string $mainLanguageCode): ContentCreateStruct;
/**
* Instantiates a new content meta data update struct.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentMetadataUpdateStruct
*/
public function newContentMetadataUpdateStruct(): ContentMetadataUpdateStruct;
/**
* Instantiates a new content update struct.
*
* @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct
*/
public function newContentUpdateStruct(): ContentUpdateStruct;
/**
* Validates given content related ValueObject returning field errors structure as a result.
*
* @param array $context Additional context parameters to be used by validators.
* @param string[]|null $fieldIdentifiersToValidate List of field identifiers for partial validation or null
* for case of full validation. Empty identifiers array is equal to no validation.
*
* @return array Validation errors grouped by field definition and language code, in format:
* $returnValue[string|int $fieldDefinitionId][string $languageCode] = $fieldErrors;
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
public function validate(ValueObject $object, array $context, ?array $fieldIdentifiersToValidate = null): array;
/**
* Fetch Content items from the Repository filtered by the given conditions.
*
* @param string[] $languages a list of language codes to be added as additional constraints.
* If skipped, by default, unless SiteAccessAware layer has been disabled, languages set
* for a SiteAccess in a current context will be used.
*/
public function find(Filter $filter, ?array $languages = null): ContentList;
/**
* Count total number of items returned by {@see ContentService::find()} method.
*
* @param string[] $languages a list of language codes to be added as additional constraints.
* If skipped, by default, unless SiteAccessAware layer has been disabled, languages set
* for a SiteAccess in a current context will be used.
*/
public function count(Filter $filter, ?array $languages = null): int;
}
class_alias(ContentService::class, 'eZ\Publish\API\Repository\ContentService');