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¶
addRelation() ¶
Creates a relation between $sourceContentId in $sourceContentVersionNo and $destinationContentId with a specific $type.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$createStruct | CreateStruct | - | - |
Return values
copy() ¶
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
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
Tags
countDraftsForUser() ¶
Returns the number of versions with draft status created by the given $userId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$userId | int | - | - |
Return values
int
countRelations() ¶
Counts all outgoing relations for the given version.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$sourceContentId | int | - | - |
$sourceContentVersionNo | int|null | null | - |
$type | int|null | null | - |
Return values
int
countReverseRelations() ¶
Counts relations from $destinationContentId only against published versions. Optionally, count only those with $type.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$destinationContentId | int | - |
Destination Content ID |
$type | int|null | null |
The relation type bitmask Relation |
Return values
int
create() ¶
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
Name | Type | Default value | Description |
---|---|---|---|
$content | CreateStruct | - |
Content creation struct. |
Return values
Content value object
createDraftFromVersion() ¶
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
Name | Type | Default value | Description |
---|---|---|---|
$contentId | mixed | - | - |
$srcVersion | mixed | - | - |
$userId | mixed | - | - |
$languageCode | string|null | null | - |
Return values
deleteContent() ¶
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
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
Return values
bool
deleteTranslationFromContent() ¶
Delete the specified translation from all the Versions of a Content Object.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$languageCode | string | - |
language code of the translation |
deleteTranslationFromDraft() ¶
Remove the specified Translation from the given Version Draft of a Content Object.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$versionNo | int | - | - |
$languageCode | string | - | - |
Return values
The Content Draft w/o removed Translation
deleteVersion() ¶
Deletes given version, its fields, node assignment, relations and names.
|
|
Removes the relations, but not the related objects.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$versionNo | int | - | - |
Return values
bool
listVersions() ¶
Returns the versions for $contentId.
|
|
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>
load() ¶
Returns the raw data of a content object identified by $id, in a struct.
|
|
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 value object
loadContentInfo() ¶
Returns the metadata object for a content identified by $contentId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int|string | - | - |
Return values
loadContentInfoByRemoteId() ¶
Returns the metadata object for a content identified by $remoteId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$remoteId | mixed | - | - |
Return values
loadContentInfoList() ¶
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
Name | Type | Default value | Description |
---|---|---|---|
$contentIds | array<string|int, mixed> | - | - |
Return values
array<string|int, ContentInfo>
loadContentList() ¶
Return list of unique Content, 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.
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>
loadDraftListForUser() ¶
Loads drafts for a user when content is not in the trash. The list is sorted by modification date.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$userId | int | - | - |
$offset | int | 0 | - |
$limit | int | -1 | - |
Return values
array<string|int, VersionInfo>
loadDraftsForUser() ¶
Returns all versions with draft status created by the given $userId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$userId | int | - | - |
Return values
array<string|int, VersionInfo>
loadRelation() ¶
Load a relation by $relationId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$relationId | int | - | - |
Return values
loadRelationList() ¶
|
|
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>
loadRelations() ¶
Loads relations from $sourceContentId. Optionally, loads only those with $type and $sourceContentVersionNo.
|
|
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
loadReverseRelationList() ¶
Loads paginated relations from $contentId. Optionally, loads only those with $type.
|
|
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>
loadReverseRelations() ¶
Loads relations from $contentId. Optionally, loads only those with $type.
|
|
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>
loadVersionInfo() ¶
Returns the version object for a content/version identified by $contentId and $versionNo.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int|string | - | - |
$versionNo | int|null | null |
Version number to load, loads current version if null. |
Return values
Tags
loadVersionInfoList() ¶
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentIds | array<string|int, int> | - | - |
Return values
array<string|int, VersionInfo>
Tags
publish() ¶
Performs the publishing operations required to set the version identified by $updateStruct->versionNo and $updateStruct->id as the published one.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$versionNo | int | - | - |
$metaDataUpdateStruct | MetadataUpdateStruct | - | - |
Return values
The published Content
Tags
removeRelation() ¶
Removes a relation by relation Id.
|
|
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 |
setStatus() ¶
Sets the status of object identified by $contentId and $version to $status.
|
|
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
updateContent() ¶
Updates a content version, identified by $contentId and $versionNo.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$versionNo | int | - | - |
$content | UpdateStruct | - | - |
Return values
updateMetadata() ¶
Updates a content object meta data, identified by $contentId.
|
|
Parameters
Name | Type | Default value | Description |
---|---|---|---|
$contentId | int | - | - |
$content | MetadataUpdateStruct | - | - |