Copied!

Handler

Handler.php : 19

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

publicaddRelation()

Handler.php : 262

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

public addRelation(CreateStruct $createStruct) : Relation

Parameters

Name Type Default value Description
$createStruct CreateStruct - -

Return values

Relation

publiccopy()

Handler.php : 250

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

public copy(mixed $contentId[, mixed|null $versionNo = null ][, int|null $newOwnerId = null ]) : Content

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

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

Copy all versions if left null

$newOwnerId int|null null

By default owner is same content we copy, for other cases set owner here to change it. E.g. In order to give person copying access to edit (if owner limitation), use this to set copier as owner.

Return values

Content

Tags
Throws
NotFoundException

If content or version is not found

publiccountDraftsForUser()

Handler.php : 141

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

public countDraftsForUser(int $userId) : int

Parameters

Name Type Default value Description
$userId int - -

Return values

int

publiccountRelations()

Handler.php : 302

Counts all outgoing relations for the given version.

public countRelations(int $sourceContentId[, int|null $sourceContentVersionNo = null ][, int|null $type = null ]) : int

Parameters

Name Type Default value Description
$sourceContentId int - -
$sourceContentVersionNo int|null null -
$type int|null null -

Return values

int

publiccountReverseRelations()

Handler.php : 327

Counts relations from $destinationContentId only against published versions. Optionally, count only those with $type.

public countReverseRelations(int $destinationContentId[, int|null $type = null ]) : int

Parameters

Name Type Default value Description
$destinationContentId int -

Destination Content ID

$type int|null null

The relation type bitmask Relation

Return values

int

publiccreate()

Handler.php : 33

Creates a new Content entity in the storage engine.

public create(CreateStruct $content) : Content

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

Will contain always a complete list of fields.

Parameters

Name Type Default value Description
$content CreateStruct -

Content creation struct.

Return values

Content

Content value object

publiccreateDraftFromVersion()

Handler.php : 48

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

public createDraftFromVersion(mixed $contentId, mixed $srcVersion, mixed $userId[, string|null $languageCode = null ]) : Content

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

Parameters

Name Type Default value Description
$contentId mixed - -
$srcVersion mixed - -
$userId mixed - -
$languageCode string|null null -

Return values

Content

publicdeleteContent()

Handler.php : 208

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

public deleteContent(int $contentId) : bool

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

Parameters

Name Type Default value Description
$contentId int - -

Return values

bool

publicdeleteTranslationFromContent()

Handler.php : 383

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

public deleteTranslationFromContent(int $contentId, string $languageCode) : mixed

Parameters

Name Type Default value Description
$contentId int - -
$languageCode string -

language code of the translation

publicdeleteTranslationFromDraft()

Handler.php : 394

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

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

Parameters

Name Type Default value Description
$contentId int - -
$versionNo int - -
$languageCode string - -

Return values

Content

The Content Draft w/o removed Translation

publicdeleteVersion()

Handler.php : 220

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

public deleteVersion(int $contentId, int $versionNo) : bool

Removes the relations, but not the related objects.

Parameters

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

Return values

bool

publiclistVersions()

Handler.php : 233

Returns the versions for $contentId.

public listVersions(int $contentId[, mixed|null $status = null ][, int $limit = -1 ]) : array<string|int, VersionInfo>

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

Parameters

Name Type Default value Description
$contentId int - -
$status mixed|null null

Optional argument to filter versions by status, like VersionInfo::STATUS_ARCHIVED.

$limit int -1

Limit for items returned, -1 means none.

Return values

array<string|int, VersionInfo>

publicload()

Handler.php : 67

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

public load(int|string $id[, int|null $version = null ][, array<string|int, string>|null $translations = null ]) : Content

If you want to load current version, $version number can be omitted to make sure you don't need to rely on search index (async) or having to load in two steps (first content info then content, risking changes in between to current version).

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

Name Type Default value Description
$id int|string - -
$version int|null null -
$translations array<string|int, string>|null null -

Return values

Content

Content value object

publicloadContentInfo()

Handler.php : 99

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

public loadContentInfo(int|string $contentId) : ContentInfo

Parameters

Name Type Default value Description
$contentId int|string - -

Return values

ContentInfo

publicloadContentInfoByRemoteId()

Handler.php : 120

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

public loadContentInfoByRemoteId(mixed $remoteId) : ContentInfo

Parameters

Name Type Default value Description
$remoteId mixed - -

Return values

ContentInfo

publicloadContentInfoList()

Handler.php : 111

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

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

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

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

Return values

array<string|int, ContentInfo>

publicloadContentList()

Handler.php : 90

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

public loadContentList(array<string|int, int> $contentIds[, array<string|int, string>|null $translations = null ]) : array<string|int, Content>

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.

If items are missing but for other reasons then not being found, for instance exceptions during loading field data. Then the exception will be logged as warning or error depending on severity. The most common case of possible exceptions during loading of Content data is migration, where either custom Field Type configuration or implementation might not be aligned with new version of the system.

NOTE!!: If you want to take always available flag into account, append main language to the list of languages(unless caller is asking for all languages). In some edge cases you'll end up with a bit more data returned, but upside is that storage engine is able to handle far larger datasets.

Parameters

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

Return values

array<string|int, Content>

publicloadDraftListForUser()

Handler.php : 161

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

public loadDraftListForUser(int $userId[, int $offset = 0 ][, int $limit = -1 ]) : array<string|int, VersionInfo>

Parameters

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

Return values

array<string|int, VersionInfo>

publicloadDraftsForUser()

Handler.php : 150

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

public loadDraftsForUser(int $userId) : array<string|int, VersionInfo>

Parameters

Name Type Default value Description
$userId int - -

Return values

array<string|int, VersionInfo>

publicloadRelation()

Handler.php : 267

Load a relation by $relationId.

public loadRelation(int $relationId) : Relation

Parameters

Name Type Default value Description
$relationId int - -

Return values

Relation

publicloadRelationList()

Handler.php : 311
public loadRelationList(int $sourceContentId, int $limit[, int $offset = 0 ][, int|null $sourceContentVersionNo = null ][, int|null $type = null ]) : array<string|int, Relation>

Parameters

Name Type Default value Description
$sourceContentId int - -
$limit int - -
$offset int 0 -
$sourceContentVersionNo int|null null -
$type int|null null -

Return values

array<string|int, Relation>

publicloadRelations()

Handler.php : 297

Loads relations from $sourceContentId. Optionally, loads only those with $type and $sourceContentVersionNo.

public loadRelations(mixed $sourceContentId[, mixed|null $sourceContentVersionNo = null ][, int|null $type = null ]) : array<string|int, Relation>

Parameters

Name Type Default value Description
$sourceContentId mixed -

Source Content ID

$sourceContentVersionNo mixed|null null

Source Content Version, null if not specified

$type int|null null

\Ibexa\Contracts\Core\Repository\Values\Content\Relation::COMMON, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::EMBED, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::LINK, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::FIELD

Return values

array<string|int, Relation>

Tags
Deprecated
4.5.7

The "ContentService::loadRelations()" method is deprecated, will be removed in 5.0.

publicloadReverseRelationList()

Handler.php : 356

Loads paginated relations from $contentId. Optionally, loads only those with $type.

public loadReverseRelationList(int $destinationContentId[, int $offset = 0 ][, int $limit = -1 ][, int|null $type = null ]) : array<string|int, Relation>

Only loads relations against published versions.

Parameters

Name Type Default value Description
$destinationContentId int -

Destination Content ID

$offset int 0 -
$limit int -1 -
$type int|null null

The relation type bitmask Relation

Return values

array<string|int, Relation>

publicloadReverseRelations()

Handler.php : 342

Loads relations from $contentId. Optionally, loads only those with $type.

public loadReverseRelations(mixed $destinationContentId[, int|null $type = null ]) : array<string|int, Relation>

Only loads relations against published versions.

Parameters

Name Type Default value Description
$destinationContentId mixed -

Destination Content ID

$type int|null null

\Ibexa\Contracts\Core\Repository\Values\Content\Relation::COMMON, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::EMBED, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::LINK, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::FIELD

Return values

array<string|int, Relation>

publicloadVersionInfo()

Handler.php : 132

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

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

Parameters

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

Version number to load, loads current version if null.

Return values

VersionInfo

Tags
Throws
NotFoundException

If version is not found

publicloadVersionInfoList()

Handler.php : 404
public loadVersionInfoList(array<string|int, int> $contentIds) : array<string|int, VersionInfo>

Parameters

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

Return values

array<string|int, VersionInfo>

Tags
Throws
InvalidArgumentException
Throws
NotFoundException

publicpublish()

Handler.php : 375

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

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

Parameters

Name Type Default value Description
$contentId int - -
$versionNo int - -
$metaDataUpdateStruct MetadataUpdateStruct - -

Return values

Content

The published Content

Tags
Throws
BadStateException

publicremoveRelation()

Handler.php : 281

Removes a relation by relation Id.

public removeRelation(int $relationId, int $type[, int|null $destinationContentId = null ]) : mixed

Parameters

Name Type Default value Description
$relationId int - -
$type int -

\Ibexa\Contracts\Core\Repository\Values\Content\Relation::COMMON, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::EMBED, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::LINK, \Ibexa\Contracts\Core\Repository\Values\Content\Relation::FIELD

$destinationContentId int|null null

Content id to invalidate cache tag related to content reverse relations count

publicsetStatus()

Handler.php : 175

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

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

The $status can be one of VersionInfo::STATUS_DRAFT, VersionInfo::STATUS_PUBLISHED, VersionInfo::STATUS_ARCHIVED When status is set to VersionInfo::STATUS_PUBLISHED content status is updated to ContentInfo::STATUS_PUBLISHED

Parameters

Name Type Default value Description
$contentId int - -
$status int - -
$version int - -

Return values

bool

publicupdateContent()

Handler.php : 196

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

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

Parameters

Name Type Default value Description
$contentId int - -
$versionNo int - -
$content UpdateStruct - -

Return values

Content

publicupdateMetadata()

Handler.php : 185

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

public updateMetadata(int $contentId, MetadataUpdateStruct $content) : ContentInfo

Parameters

Name Type Default value Description
$contentId int - -
$content MetadataUpdateStruct - -

Return values

ContentInfo