Copied!

ContentServiceDecorator

ContentServiceDecorator.php : 29
Implements ContentService

Properties

protected $innerService

ContentServiceDecorator.php : 32
protected ContentService $innerService

Methods

public__construct()

ContentServiceDecorator.php : 34
public __construct(ContentService $innerService)

Parameters

Name Type Default value Description
$innerService ContentService - -

publicaddRelation()

ContentServiceDecorator.php : 221

Adds a relation of type common.

public addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) : Relation

The source of the relation is the content and version referenced by $versionInfo.

Parameters

Name Type Default value Description
$sourceVersion VersionInfo - -
$destinationContent ContentInfo -

the destination of the relation

Return values

Relation

the newly created relation

publiccopyContent()

ContentServiceDecorator.php : 183

Copies the content to a new location. If no version is given, all versions are copied, otherwise only the given version.

public copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct[, VersionInfo|null $versionInfo = null ]) : Content

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$destinationLocationCreateStruct LocationCreateStruct -

the target location where the content is copied to

$versionInfo VersionInfo|null null -

Return values

Content

publiccount()

ContentServiceDecorator.php : 289

Count total number of items returned by {@see ContentService::find()} method.

public count(Filter $filter[, array<string|int, mixed>|null $languages = null ]) : int

Parameters

Name Type Default value Description
$filter Filter - -
$languages array<string|int, mixed>|null null

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.

Return values

int

publiccountContentDrafts()

ContentServiceDecorator.php : 145

Counts drafts for a user.

public countContentDrafts([User $user = null ]) : int

If no user is given the number of drafts for the authenticated user are returned

Parameters

Name Type Default value Description
$user User null

The user to load drafts for, if defined, otherwise drafts for current-user

Return values

int

The number of drafts (VersionInfo) owned by the given user

publiccountRelations()

ContentServiceDecorator.php : 196

Counts all outgoing relations for the given version.

public countRelations(VersionInfo $versionInfo) : int

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -

Return values

int

publiccountReverseRelations()

ContentServiceDecorator.php : 206

Counts all incoming relations for the given content object.

public countReverseRelations(ContentInfo $contentInfo) : int

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -

Return values

int

The number of reverse relations (Relation)

publiccreateContent()

ContentServiceDecorator.php : 116

Creates a new content draft assigned to the authenticated user.

public createContent(ContentCreateStruct $contentCreateStruct[, array<string|int, mixed> $locationCreateStructs = [] ][, array<string|int, mixed>|null $fieldIdentifiersToValidate = null ]) : Content

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.

Parameters

Name Type Default value Description
$contentCreateStruct ContentCreateStruct - -
$locationCreateStructs array<string|int, mixed> []

an array of 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).

$fieldIdentifiersToValidate array<string|int, mixed>|null null

List of field identifiers for partial validation or null for case of full validation. Empty identifiers array is equal to no validation.

Return values

Content

  • the newly created content draft

publiccreateContentDraft()

ContentServiceDecorator.php : 136

Creates a draft from a published or archived version.

public createContentDraft(ContentInfo $contentInfo[, VersionInfo|null $versionInfo = null ][, User|null $creator = null ][, Language|null $language = null ]) : Content

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.

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$versionInfo VersionInfo|null null -
$creator User|null null

Used as creator of the draft if given - otherwise uses current-user

$language Language|null null -

Return values

Content

  • the newly created content draft

publicdeleteContent()

ContentServiceDecorator.php : 131

Deletes a content object including all its versions and locations including their subtrees.

public deleteContent(ContentInfo $contentInfo) : array<string|int, int>

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -

Return values

array<string|int, int>

Affected Location Id's (List of Locations of the Content that was deleted)

publicdeleteRelation()

ContentServiceDecorator.php : 228

Removes a relation of type COMMON from a draft.

public deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent) : void

Parameters

Name Type Default value Description
$sourceVersion VersionInfo - -
$destinationContent ContentInfo - -

publicdeleteTranslation()

ContentServiceDecorator.php : 235

Delete Content item Translation from all Versions (including archived ones) of a Content Object.

public deleteTranslation(ContentInfo $contentInfo, string $languageCode) : void

NOTE: this operation is risky and permanent, so user interface should provide a warning before performing it.

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$languageCode string - -

publicdeleteTranslationFromDraft()

ContentServiceDecorator.php : 242

Delete specified Translation from a Content Draft.

public deleteTranslationFromDraft(VersionInfo $versionInfo, string $languageCode) : Content

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.

Parameters

Name Type Default value Description
$versionInfo VersionInfo -

Content Version Draft

$languageCode string -

Language code of the Translation to be removed

Return values

Content

Content Draft w/o the specified Translation

publicdeleteVersion()

ContentServiceDecorator.php : 173

Removes the given version.

public deleteVersion(VersionInfo $versionInfo) : void

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -

publicfind()

ContentServiceDecorator.php : 284

Fetch Content items from the Repository filtered by the given conditions.

public find(Filter $filter[, array<string|int, mixed>|null $languages = null ]) : ContentList

Parameters

Name Type Default value Description
$filter Filter - -
$languages array<string|int, mixed>|null null

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.

Return values

ContentList

publichideContent()

ContentServiceDecorator.php : 249

Hides Content by making all the Locations appear hidden.

public hideContent(ContentInfo $contentInfo) : void

It does not persist hidden state on Location object itself.

Content hidden by this API can be revealed by revealContent API.

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -

publicloadContent()

ContentServiceDecorator.php : 90

Loads content in a version of the given content object.

public loadContent(int $contentId[, array<string|int, mixed> $languages = null ][, int|null $versionNo = null ][, bool $useAlwaysAvailable = true ]) : Content

If no version number is given, the method returns the current version

Parameters

Name Type Default value Description
$contentId int - -
$languages array<string|int, mixed> null

A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.

$versionNo int|null null

the version number. If not given the current version is returned

$useAlwaysAvailable bool true

Add Main language to $languages if true (default) and if alwaysAvailable is true

Return values

Content

publicloadContentByContentInfo()

ContentServiceDecorator.php : 73

Loads content in a version for the given content info object.

public loadContentByContentInfo(ContentInfo $contentInfo[, array<string|int, mixed> $languages = null ][, int|null $versionNo = null ][, bool $useAlwaysAvailable = true ]) : Content

If no version number is given, the method returns the current version

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$languages array<string|int, mixed> null

A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.

$versionNo int|null null

the version number. If not given the current version is returned from $contentInfo

$useAlwaysAvailable bool true

Add Main language to $languages if true (default) and if alwaysAvailable is true

Return values

Content

publicloadContentByRemoteId()

ContentServiceDecorator.php : 99

Loads content in a version for the content object reference by the given remote id.

public loadContentByRemoteId(string $remoteId[, array<string|int, mixed> $languages = null ][, int|null $versionNo = null ][, bool $useAlwaysAvailable = true ]) : Content

If no version is given, the method returns the current version

Parameters

Name Type Default value Description
$remoteId string - -
$languages array<string|int, mixed> null

A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.

$versionNo int|null null

the version number. If not given the current version is returned

$useAlwaysAvailable bool true

Add Main language to $languages if true (default) and if alwaysAvailable is true

Return values

Content

publicloadContentByVersionInfo()

ContentServiceDecorator.php : 82

Loads content in the version given by version info.

public loadContentByVersionInfo(VersionInfo $versionInfo[, array<string|int, mixed> $languages = null ][, bool $useAlwaysAvailable = true ]) : Content

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -
$languages array<string|int, mixed> null

A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.

$useAlwaysAvailable bool true

Add Main language to $languages if true (default) and if alwaysAvailable is true

Return values

Content

publicloadContentDraftList()

ContentServiceDecorator.php : 155

Loads drafts for a user when content is not in the trash. The list is sorted by modification date.

public loadContentDraftList([User|null $user = null ][, int $offset = 0 ][, int $limit = -1 ]) : ContentDraftList

If no user is given the drafts for the authenticated user are returned

Parameters

Name Type Default value Description
$user User|null null

The user to load drafts for, if defined, otherwise drafts for current-user

$offset int 0 -
$limit int -1 -

Return values

ContentDraftList

publicloadContentDrafts()

ContentServiceDecorator.php : 150

Loads drafts for a user.

public loadContentDrafts([User|null $user = null ]) : array<string|int, VersionInfo>

If no user is given the drafts for the authenticated user are returned

Parameters

Name Type Default value Description
$user User|null null

The user to load drafts for, if defined, otherwise drafts for current-user

Return values

array<string|int, VersionInfo>

the drafts (VersionInfo) owned by the given user

publicloadContentInfo()

ContentServiceDecorator.php : 39

Loads a content info object.

public loadContentInfo(int $contentId) : ContentInfo

To load fields use loadContent

Parameters

Name Type Default value Description
$contentId int - -

Return values

ContentInfo

publicloadContentInfoByRemoteId()

ContentServiceDecorator.php : 49

Loads a content info object for the given remoteId.

public loadContentInfoByRemoteId(string $remoteId) : ContentInfo

To load fields use loadContent

Parameters

Name Type Default value Description
$remoteId string - -

Return values

ContentInfo

publicloadContentInfoList()

ContentServiceDecorator.php : 44

Bulk-load ContentInfo items by id's.

public loadContentInfoList(array<string|int, mixed> $contentIds) : array<string|int, ContentInfo>

Note: It does not throw exceptions on load, just skips erroneous (NotFound or Unauthorized) ContentInfo items.

Parameters

Name Type Default value Description
$contentIds array<string|int, mixed> - -

Return values

array<string|int, ContentInfo>

list of ContentInfo with Content Ids as keys

publicloadContentListByContentInfo()

ContentServiceDecorator.php : 108

Bulk-load Content items by the list of ContentInfo Value Objects.

public loadContentListByContentInfo(array<string|int, mixed> $contentInfoList[, array<string|int, mixed> $languages = [] ][, bool $useAlwaysAvailable = true ]) : array<string|int, Content>

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.

Parameters

Name Type Default value Description
$contentInfoList array<string|int, mixed> - -
$languages array<string|int, mixed> []

A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.

$useAlwaysAvailable bool true

Add Main language to $languages if true (default) and if alwaysAvailable is true, unless all languages have been asked for.

Return values

array<string|int, Content>

list of Content items with Content Ids as keys

publicloadRelationList()

ContentServiceDecorator.php : 201

Loads all outgoing relations for the given version.

public loadRelationList(VersionInfo $versionInfo[, int $offset = 0 ][, int $limit = self::DEFAULT_PAGE_SIZE ]) : RelationList

If the user is not allowed to read specific version then a returned RelationList will contain UnauthorizedRelationListItem

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -
$offset int 0 -
$limit int ContentServiceDecorator::DEFAULT_PAGE_SIZE -

Return values

RelationList

publicloadRelations()

ContentServiceDecorator.php : 191

Loads all outgoing relations for the given version.

public loadRelations(VersionInfo $versionInfo) : array<string|int, Relation>

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -

Return values

array<string|int, Relation>

publicloadReverseRelationList()

ContentServiceDecorator.php : 216

Loads all incoming relations for a content object.

public loadReverseRelationList(ContentInfo $contentInfo[, int $offset = 0 ][, int $limit = -1 ]) : RelationList

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 UnauthorizedRelationListItem

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$offset int 0 -
$limit int -1 -

Return values

RelationList

publicloadReverseRelations()

ContentServiceDecorator.php : 211

Loads all incoming relations for a content object.

public loadReverseRelations(ContentInfo $contentInfo) : array<string|int, Relation>

The relations come only from published versions of the source content objects

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -

Return values

array<string|int, Relation>

publicloadVersionInfo()

ContentServiceDecorator.php : 54

Loads a version info of the given content object.

public loadVersionInfo(ContentInfo $contentInfo[, int|null $versionNo = null ]) : VersionInfo

If no version number is given, the method returns the current version

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$versionNo int|null null

the version number. If not given the current version is returned.

Return values

VersionInfo

publicloadVersionInfoById()

ContentServiceDecorator.php : 61

Loads a version info of the given content object id.

public loadVersionInfoById(int $contentId[, int|null $versionNo = null ]) : VersionInfo

If no version number is given, the method returns the current version

Parameters

Name Type Default value Description
$contentId int - -
$versionNo int|null null

the version number. If not given the current version is returned.

Return values

VersionInfo

publicloadVersionInfoListByContentInfo()

ContentServiceDecorator.php : 68

Bulk-load VersionInfo items by the list of ContentInfo Value Objects.

public loadVersionInfoListByContentInfo(array<string|int, mixed> $contentInfoList) : array<int, VersionInfo>

Parameters

Name Type Default value Description
$contentInfoList array<string|int, mixed> - -

Return values

array<int, VersionInfo>

List of VersionInfo items with Content Ids as keys

publicloadVersions()

ContentServiceDecorator.php : 178

Loads all versions for the given content.

public loadVersions(ContentInfo $contentInfo[, int|null $status = null ]) : array<string|int, VersionInfo>

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$status int|null null -

Return values

array<string|int, VersionInfo>

an array of VersionInfo sorted by creation date

publicnewContentCreateStruct()

ContentServiceDecorator.php : 259

Instantiates a new content create struct object.

public newContentCreateStruct(ContentType $contentType, string $mainLanguageCode) : ContentCreateStruct

alwaysAvailable is set to the ContentType's defaultAlwaysAvailable

Parameters

Name Type Default value Description
$contentType ContentType - -
$mainLanguageCode string - -

Return values

ContentCreateStruct

publicnewContentMetadataUpdateStruct()

ContentServiceDecorator.php : 266

Instantiates a new content meta data update struct.

public newContentMetadataUpdateStruct() : ContentMetadataUpdateStruct

Return values

ContentMetadataUpdateStruct

publicnewContentUpdateStruct()

ContentServiceDecorator.php : 271

Instantiates a new content update struct.

public newContentUpdateStruct() : ContentUpdateStruct

Return values

ContentUpdateStruct

publicpublishVersion()

ContentServiceDecorator.php : 168

Publishes a content version.

public publishVersion(VersionInfo $versionInfo[, array<string|int, mixed> $translations = Language::ALL ]) : Content

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.

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -
$translations array<string|int, mixed> Language::ALL

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 values

Content

publicrevealContent()

ContentServiceDecorator.php : 254

Reveals Content hidden by hideContent API.

public revealContent(ContentInfo $contentInfo) : void

Locations which were hidden before hiding Content will remain hidden.

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -

publicupdateContent()

ContentServiceDecorator.php : 160

Updates the fields of a draft.

public updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct[, array<string|int, mixed>|null $fieldIdentifiersToValidate = null ]) : Content

Parameters

Name Type Default value Description
$versionInfo VersionInfo - -
$contentUpdateStruct ContentUpdateStruct - -
$fieldIdentifiersToValidate array<string|int, mixed>|null null

List of field identifiers for partial validation or null for case of full validation. Empty identifiers array is equal to no validation.

Return values

Content

the content draft with the updated fields

publicupdateContentMetadata()

ContentServiceDecorator.php : 124

Updates the metadata.

public updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct) : Content

See ContentMetadataUpdateStruct of a content object - to update fields use updateContent

Parameters

Name Type Default value Description
$contentInfo ContentInfo - -
$contentMetadataUpdateStruct ContentMetadataUpdateStruct - -

Return values

Content

the content with the updated attributes

publicvalidate()

ContentServiceDecorator.php : 276

Validates given content related ValueObject returning field errors structure as a result.

public validate(ValueObject $object, array<string|int, mixed> $context[, array<string|int, mixed>|null $fieldIdentifiersToValidate = null ]) : array<string|int, mixed>

Parameters

Name Type Default value Description
$object ValueObject - -
$context array<string|int, mixed> -

Additional context parameters to be used by validators.

$fieldIdentifiersToValidate array<string|int, mixed>|null null

List of field identifiers for partial validation or null for case of full validation. Empty identifiers array is equal to no validation.

Return values

array<string|int, mixed>

Validation errors grouped by field definition and language code, in format: $returnValue[string|int $fieldDefinitionId][string $languageCode] = $fieldErrors;