Interface

eZ\Publish\SPI\Persistence\Content\Handler

interface Handler

The Content Handler interface defines content operations on the storage engine.

The basic operations which are performed on content objects are collected in this interface. Typically this interface would be used by a service managing business logic for content objects.

Methods

Content create(CreateStruct $content)

Creates a new Content entity in the storage engine.

Content createDraftFromVersion(mixed $contentId, mixed $srcVersion, mixed $userId)

Creates a new draft version from $contentId in $srcVersion number.

Content load(int|string $id, int|string $version, array $translations = null)

Returns the raw data of a content object identified by $id, in a struct.

ContentInfo loadContentInfo(int|string $contentId)

Returns the metadata object for a content identified by $contentId.

ContentInfo[] loadContentInfoList(array $contentIds)

Return list of unique Content Info, with content id as key.

ContentInfo loadContentInfoByRemoteId(mixed $remoteId)

Returns the metadata object for a content identified by $remoteId.

VersionInfo loadVersionInfo(int|string $contentId, int $versionNo)

Returns the version object for a content/version identified by $contentId and $versionNo.

VersionInfo[] loadDraftsForUser(int $userId)

Returns all versions with draft status created by the given $userId.

bool setStatus(int $contentId, int $status, int $version)

Sets the status of object identified by $contentId and $version to $status.

ContentInfo updateMetadata(int $contentId, MetadataUpdateStruct $content)

Updates a content object meta data, identified by $contentId.

Content updateContent(int $contentId, int $versionNo, UpdateStruct $content)

Updates a content version, identified by $contentId and $versionNo.

bool deleteContent(int $contentId)

Deletes all versions and fields, all locations (subtree), and all relations.

bool deleteVersion(int $contentId, int $versionNo)

Deletes given version, its fields, node assignment, relations and names.

VersionInfo[] listVersions(int $contentId, mixed|null $status = null, int $limit = -1)

Returns the versions for $contentId.

Content copy(mixed $contentId, mixed|null $versionNo = null)

Copy Content with Fields, Versions & Relations from $contentId in $version.

Relation addRelation(CreateStruct $createStruct)

Creates a relation between $sourceContentId in $sourceContentVersionNo and $destinationContentId with a specific $type.

removeRelation(mixed $relationId, int $type)

Removes a relation by relation Id.

Relation[] loadRelations(mixed $sourceContentId, mixed|null $sourceContentVersionNo = null, int|null $type = null)

Loads relations from $sourceContentId.

Relation[] loadReverseRelations(mixed $destinationContentId, int|null $type = null)

Loads relations from $contentId.

Content publish(int $contentId, int $versionNo, MetadataUpdateStruct $metaDataUpdateStruct)

Performs the publishing operations required to set the version identified by $updateStruct->versionNo and $updateStruct->id as the published one.

removeTranslationFromContent(int $contentId, string $languageCode)

Remove the specified translation from all the Versions of a Content Object.

deleteTranslationFromContent(int $contentId, string $languageCode)

Delete the specified translation from all the Versions of a Content Object.

Content deleteTranslationFromDraft(int $contentId, int $versionNo, string $languageCode)

Remove the specified Translation from the given Version Draft of a Content Object.

Details

at line 35
public Content create(CreateStruct $content)

Creates a new Content entity in the storage engine.

The values contained inside the $content will form the basis of stored entity.

Will contain always a complete list of fields.

Parameters

CreateStruct $content Content creation struct.

Return Value

Content Content value object

at line 49
public Content createDraftFromVersion(mixed $contentId, mixed $srcVersion, mixed $userId)

Creates a new draft version from $contentId in $srcVersion number.

Copies all fields from $contentId in $srcVersion and creates a new version of the referred Content from it.

Parameters

mixed $contentId
mixed $srcVersion
mixed $userId

Return Value

Content

at line 68
public Content load(int|string $id, int|string $version, array $translations = null)

Returns the raw data of a content object identified by $id, in a struct.

A version to load must be specified. If you want to load the current version of a content object use SearchHandler::findSingle() with the ContentId criterion.

Optionally a translation filter may be specified. If specified only the translations with the listed language codes will be retrieved. If not, all translations will be retrieved.

Parameters

int|string $id
int|string $version
array $translations

Return Value

Content Content value object

at line 77
public ContentInfo loadContentInfo(int|string $contentId)

Returns the metadata object for a content identified by $contentId.

Parameters

int|string $contentId

Return Value

ContentInfo

at line 89
public ContentInfo[] loadContentInfoList(array $contentIds)

Return list of unique Content Info, with content id as key.

Missing items (NotFound) will be missing from the array and not cause an exception, it's up to calling logic to determine if this should cause exception or not.

Parameters

array $contentIds

Return Value

ContentInfo[]

at line 98
public ContentInfo loadContentInfoByRemoteId(mixed $remoteId)

Returns the metadata object for a content identified by $remoteId.

Parameters

mixed $remoteId

Return Value

ContentInfo

at line 110
public VersionInfo loadVersionInfo(int|string $contentId, int $versionNo)

Returns the version object for a content/version identified by $contentId and $versionNo.

Parameters

int|string $contentId
int $versionNo Version number to load

Return Value

VersionInfo

Exceptions

NotFoundException If version is not found

at line 119
public VersionInfo[] loadDraftsForUser(int $userId)

Returns all versions with draft status created by the given $userId.

Parameters

int $userId

Return Value

VersionInfo[]

at line 133
public bool setStatus(int $contentId, int $status, int $version)

Sets the status of object identified by $contentId and $version to $status.

The $status can be one of VersionInfo::STATUSDRAFT, VersionInfo::STATUSPUBLISHED, VersionInfo::STATUSARCHIVED When status is set to VersionInfo::STATUSPUBLISHED content status is updated to ContentInfo::STATUS_PUBLISHED

Parameters

int $contentId
int $status
int $version

Return Value

bool

at line 143
public ContentInfo updateMetadata(int $contentId, MetadataUpdateStruct $content)

Updates a content object meta data, identified by $contentId.

Parameters

int $contentId
MetadataUpdateStruct $content

Return Value

ContentInfo

at line 154
public Content updateContent(int $contentId, int $versionNo, UpdateStruct $content)

Updates a content version, identified by $contentId and $versionNo.

Parameters

int $contentId
int $versionNo
UpdateStruct $content

Return Value

Content

at line 166
public bool deleteContent(int $contentId)

Deletes all versions and fields, all locations (subtree), and all relations.

Removes the relations, but not the related objects. All subtrees of the assigned nodes of this content objects are removed (recursively).

Parameters

int $contentId

Return Value

bool

at line 178
public bool deleteVersion(int $contentId, int $versionNo)

Deletes given version, its fields, node assignment, relations and names.

Removes the relations, but not the related objects.

Parameters

int $contentId
int $versionNo

Return Value

bool

at line 191
public VersionInfo[] listVersions(int $contentId, mixed|null $status = null, int $limit = -1)

Returns the versions for $contentId.

Result is returned with oldest version first (sorted by created, alternatively version number or id if auto increment).

Parameters

int $contentId
mixed|null $status Optional argument to filter versions by status, like {see VersionInfo::STATUS_ARCHIVED}.
int $limit Limit for items returned, -1 means none.

Return Value

VersionInfo[]

at line 206
public Content copy(mixed $contentId, mixed|null $versionNo = null)

Copy Content with Fields, Versions & Relations from $contentId in $version.

Copies all fields and relations from $contentId in $version (or all versions if false) to a new object which is returned. Version numbers are maintained.

Parameters

mixed $contentId
mixed|null $versionNo Copy all versions if left null

Return Value

Content

Exceptions

NotFoundException If content or version is not found

at line 218
public Relation addRelation(CreateStruct $createStruct)

Creates a relation between $sourceContentId in $sourceContentVersionNo and $destinationContentId with a specific $type.

Parameters

CreateStruct $createStruct

Return Value

Relation

at line 231
public removeRelation(mixed $relationId, int $type)

Removes a relation by relation Id.

Parameters

mixed $relationId
int $type {see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON, \eZ\Publish\API\Repository\Values\Content\Relation::EMBED, \eZ\Publish\API\Repository\Values\Content\Relation::LINK, \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}

at line 245
public Relation[] loadRelations(mixed $sourceContentId, mixed|null $sourceContentVersionNo = null, int|null $type = null)

Loads relations from $sourceContentId.

Optionally, loads only those with $type and $sourceContentVersionNo.

Parameters

mixed $sourceContentId Source Content ID
mixed|null $sourceContentVersionNo Source Content Version, null if not specified
int|null $type {see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON, \eZ\Publish\API\Repository\Values\Content\Relation::EMBED, \eZ\Publish\API\Repository\Values\Content\Relation::LINK, \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}

Return Value

Relation[]

at line 260
public Relation[] loadReverseRelations(mixed $destinationContentId, int|null $type = null)

Loads relations from $contentId.

Optionally, loads only those with $type.

Only loads relations against published versions.

Parameters

mixed $destinationContentId Destination Content ID
int|null $type {see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON, \eZ\Publish\API\Repository\Values\Content\Relation::EMBED, \eZ\Publish\API\Repository\Values\Content\Relation::LINK, \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}

Return Value

Relation[]

at line 272
public Content publish(int $contentId, int $versionNo, MetadataUpdateStruct $metaDataUpdateStruct)

Performs the publishing operations required to set the version identified by $updateStruct->versionNo and $updateStruct->id as the published one.

Parameters

int $contentId
int $versionNo
MetadataUpdateStruct $metaDataUpdateStruct

Return Value

Content The published Content

at line 282
public removeTranslationFromContent(int $contentId, string $languageCode)

Remove the specified translation from all the Versions of a Content Object.

Parameters

int $contentId
string $languageCode language code of the translation

at line 290
public deleteTranslationFromContent(int $contentId, string $languageCode)

Delete the specified translation from all the Versions of a Content Object.

Parameters

int $contentId
string $languageCode language code of the translation

at line 301
public Content deleteTranslationFromDraft(int $contentId, int $versionNo, string $languageCode)

Remove the specified Translation from the given Version Draft of a Content Object.

Parameters

int $contentId
int $versionNo
string $languageCode

Return Value

Content The Content Draft w/o removed Translation