Class

eZ\Publish\Core\Persistence\Legacy\Content\Handler

class Handler implements Handler

The Content Handler stores Content and ContentType objects.

Methods

__construct(Gateway $contentGateway, Gateway $locationGateway, Mapper $mapper, FieldHandler $fieldHandler, SlugConverter $slugConverter, Gateway $urlAliasGateway, Handler $contentTypeHandler, TreeHandler $treeHandler)

Creates a new content handler.

Content create(CreateStruct $struct)

Creates a new Content entity in the storage engine.

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.

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

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

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 $updateStruct)

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

bool deleteContent(int $contentId)

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

removeRawContent(int $contentId)

Deletes raw content data.

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.

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 97
public __construct(Gateway $contentGateway, Gateway $locationGateway, Mapper $mapper, FieldHandler $fieldHandler, SlugConverter $slugConverter, Gateway $urlAliasGateway, Handler $contentTypeHandler, TreeHandler $treeHandler)

Creates a new content handler.

Parameters

Gateway $contentGateway
Gateway $locationGateway
Mapper $mapper
FieldHandler $fieldHandler
SlugConverter $slugConverter
Gateway $urlAliasGateway
Handler $contentTypeHandler
TreeHandler $treeHandler

at line 129
public Content create(CreateStruct $struct)

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 $struct Content creation struct.

Return Value

Content Content value object

at line 204
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.

The publish procedure will: - Create location nodes based on the node assignments - Update the content object using the provided metadata update struct - Update the node assignments - Update location nodes of the content with the new published version - Set content and version status to published

Parameters

int $contentId
int $versionNo
MetadataUpdateStruct $metaDataUpdateStruct

Return Value

Content The published Content

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

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

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

Note: When creating a new draft in the old admin interface there will also be an entry in the eznode_assignment created for the draft. This is ignored in this implementation.

Parameters

mixed $contentId
mixed $srcVersion
mixed $userId

Return Value

Content

at line 311
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 337
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 342
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 363
public ContentInfo loadContentInfoByRemoteId(mixed $remoteId)

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

Parameters

mixed $remoteId

Return Value

ContentInfo

at line 380
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 402
public VersionInfo[] loadDraftsForUser(int $userId)

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

Parameters

int $userId

Return Value

VersionInfo[]

at line 435
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 448
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 501
public Content updateContent(int $contentId, int $versionNo, UpdateStruct $updateStruct)

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

Parameters

int $contentId
int $versionNo
UpdateStruct $updateStruct

Return Value

Content

at line 529
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 546
public removeRawContent(int $contentId)

Deletes raw content data.

Parameters

int $contentId

at line 561
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 585
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 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 602
public Content copy(mixed $contentId, mixed|null $versionNo = null)

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

{@inheritdoc}

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 666
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 686
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 703
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 723
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 733
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 745
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 758
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