Class

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase

class DoctrineDatabase extends Gateway

Doctrine database based content gateway.

Methods

array getContext()

Get context definition for external storage layers.

int insertContentObject(CreateStruct $struct, mixed $currentVersionNo = 1)

Inserts a new content object.

int insertVersion(VersionInfo $versionInfo, array $fields)

Inserts a new version.

updateContent(int $contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null)

Updates an existing content identified by $contentId in respect to $struct.

updateVersion(int $contentId, int $versionNo, UpdateStruct $struct)

Updates version $versionNo for content identified by $contentId, in respect to $struct.

updateAlwaysAvailableFlag(int $contentId, bool|null $alwaysAvailable = null)

Updates "always available" flag for Content identified by $contentId, in respect to Content's current main language and optionally new $alwaysAvailable state.

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

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

int insertNewField(Content $content, Field $field, StorageFieldValue $value)

Inserts a new field.

insertExistingField(Content $content, Field $field, StorageFieldValue $value)

Inserts an existing field.

updateField(Field $field, StorageFieldValue $value)

Updates an existing field.

updateNonTranslatableField(Field $field, StorageFieldValue $value, int $contentId)

Updates an existing, non-translatable field.

array load(mixed $contentId, mixed $version, array $translations = null)

Loads data for a content object.

array loadContentInfoByRemoteId(mixed $remoteId)

Loads info for a content object identified by its remote ID.

array loadContentInfo(int $contentId)

Loads info for content identified by $contentId.

array loadVersionInfo(int $contentId, int $versionNo)

Loads version info for content identified by $contentId and $versionNo.

string[][] listVersionsForUser(int $userId, int $status = VersionInfo::STATUS_DRAFT)

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

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

Returns all version data for the given $contentId, optionally filtered by status.

int[] listVersionNumbers(mixed $contentId)

Returns all version numbers for the given $contentId.

int getLastVersionNumber(int $contentId)

Returns last version number for content identified by $contentId.

int[] getAllLocationIds(int $contentId)

Returns all IDs for locations that refer to $contentId.

int[][] getFieldIdsByType(int $contentId, int|null $versionNo = null, string|null $languageCode = null)

Returns all field IDs of $contentId grouped by their type.

deleteRelations(int $contentId, int|null $versionNo = null)

Deletes relations to and from $contentId.

removeReverseFieldRelations(int $contentId)

Removes relations to Content with $contentId from Relation and RelationList field type fields.

deleteField(int $fieldId)

Deletes the field with the given $fieldId.

deleteFields(int $contentId, int|null $versionNo = null)

Deletes all fields of $contentId in all versions.

deleteVersions(int $contentId, int|null $versionNo = null)

Deletes all versions of $contentId.

deleteNames(int $contentId, int|null $versionNo = null)

Deletes all names of $contentId.

setName(int $contentId, int $version, string $name, string $language)

Sets the name for Content $contentId in version $version to $name in $language.

deleteContent(int $contentId)

Deletes the actual content object referred to by $contentId.

string[][] loadRelations(int $contentId, int $contentVersionNo = null, int $relationType = null)

Loads relations from $contentId to published content, optionally only from $contentVersionNo.

mixed[][] loadReverseRelations(int $toContentId, int $relationType = null)

Loads data that related to $toContentId.

deleteRelation(int $relationId, int $type)

Deletes the relation with the given $relationId.

int insertRelation(CreateStruct $createStruct)

Inserts a new relation database record.

int[] getContentIdsByContentTypeId(int $contentTypeId)

Returns all Content IDs for a given $contentTypeId.

array loadVersionedNameData(array[] $rows)

Load name data for set of content id's and corresponding version number.

copyRelations(int $originalContentId, int $copiedContentId, int|null $versionNo = null)

Batch method for copying all relation meta data for copied Content object.

removeTranslationFromContent(int $contentId, string $languageCode)

Remove the specified translation from the Content Object Version.

deleteTranslatedFields(string $languageCode, int $contentId, int $versionNo = null)

Delete Content fields (attributes) for the given Translation.

deleteTranslationFromVersion(int $contentId, int $versionNo, string $languageCode)

Delete the specified Translation from the given Version.

__construct(DatabaseHandler $db, Connection $connection, QueryBuilder $queryBuilder, Handler $languageHandler, MaskGenerator $languageMaskGenerator)

Creates a new gateway based on $db.

Details

at line 107
public array getContext()

Get context definition for external storage layers.

Return Value

array

at line 123
public int insertContentObject(CreateStruct $struct, mixed $currentVersionNo = 1)

Inserts a new content object.

Parameters

CreateStruct $struct
mixed $currentVersionNo

Return Value

int ID

at line 225
public int insertVersion(VersionInfo $versionInfo, array $fields)

Inserts a new version.

Parameters

VersionInfo $versionInfo
array $fields

Return Value

int ID

at line 290
public updateContent(int $contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null)

Updates an existing content identified by $contentId in respect to $struct.

Parameters

int $contentId
MetadataUpdateStruct $struct
VersionInfo $prePublishVersionInfo Provided on publish

at line 370
public updateVersion(int $contentId, int $versionNo, UpdateStruct $struct)

Updates version $versionNo for content identified by $contentId, in respect to $struct.

Parameters

int $contentId
int $versionNo
UpdateStruct $struct

at line 420
public updateAlwaysAvailableFlag(int $contentId, bool|null $alwaysAvailable = null)

Updates "always available" flag for Content identified by $contentId, in respect to Content's current main language and optionally new $alwaysAvailable state.

Parameters

int $contentId
bool|null $alwaysAvailable New "always available" value or null if not defined

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

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

The $status can be one of STATUSDRAFT, STATUSPUBLISHED, STATUS_ARCHIVED

Parameters

int $contentId
int $version
int $status

Return Value

bool

at line 619
public int insertNewField(Content $content, Field $field, StorageFieldValue $value)

Inserts a new field.

Only used when a new field is created (i.e. a new object or a field in a new language!). After that, field IDs need to stay the same, only the version number changes.

Parameters

Content $content
Field $field
StorageFieldValue $value

Return Value

int ID

at line 647
public insertExistingField(Content $content, Field $field, StorageFieldValue $value)

Inserts an existing field.

Used to insert a field with an exsting ID but a new version number.

Parameters

Content $content
Field $field
StorageFieldValue $value

at line 738
public updateField(Field $field, StorageFieldValue $value)

Updates an existing field.

Parameters

Field $field
StorageFieldValue $value

at line 794
public updateNonTranslatableField(Field $field, StorageFieldValue $value, int $contentId)

Updates an existing, non-translatable field.

Parameters

Field $field
StorageFieldValue $value
int $contentId

at line 833
public array load(mixed $contentId, mixed $version, array $translations = null)

Loads data for a content object.

Returns an array with the relevant data.

Parameters

mixed $contentId
mixed $version
array $translations

Return Value

array

at line 930
public array loadContentInfoByRemoteId(mixed $remoteId)

Loads info for a content object identified by its remote ID.

Returns an array with the relevant data.

Parameters

mixed $remoteId

Return Value

array

Exceptions

NotFoundException

at line 914
public array loadContentInfo(int $contentId)

Loads info for content identified by $contentId.

Will basically return a hash containing all field values for ezcontentobject table plus some additional keys: - alwaysavailable => Boolean indicating if content's language mask contains alwaysAvailable bit field - mainlanguage_code => Language code for main (initial) language. E.g. "eng-GB".

Parameters

int $contentId

Return Value

array

Exceptions

NotFoundException

at line 947
public array loadVersionInfo(int $contentId, int $versionNo)

Loads version info for content identified by $contentId and $versionNo.

Will basically return a hash containing all field values from ezcontentobjectversion table plus following keys: - names => Hash of content object names. Key is the language code, value is the name. - languages => Hash of language ids. Key is the language code (e.g. "eng-GB"), value is the language numeric id without the always available bit. - initiallanguage_code => Language code for initial language in this version.

Parameters

int $contentId
int $versionNo

Return Value

array

at line 976
public string[][] listVersionsForUser(int $userId, int $status = VersionInfo::STATUS_DRAFT)

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

Parameters

int $userId
int $status

Return Value

string[][]

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

Returns all version data for the given $contentId, optionally filtered by status.

Result is returned with oldest version first (using version id as it has index and is auto increment).

Parameters

mixed $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

string[][]

at line 1072
public int[] listVersionNumbers(mixed $contentId)

Returns all version numbers for the given $contentId.

Parameters

mixed $contentId

Return Value

int[]

at line 1099
public int getLastVersionNumber(int $contentId)

Returns last version number for content identified by $contentId.

Parameters

int $contentId

Return Value

int

at line 1126
public int[] getAllLocationIds(int $contentId)

Returns all IDs for locations that refer to $contentId.

Parameters

int $contentId

Return Value

int[]

at line 1157
public int[][] getFieldIdsByType(int $contentId, int|null $versionNo = null, string|null $languageCode = null)

Returns all field IDs of $contentId grouped by their type.

If $versionNo is set only field IDs for that version are returned. If $languageCode is set, only field IDs for that language are returned.

Parameters

int $contentId
int|null $versionNo
string|null $languageCode

Return Value

int[][]

at line 1211
public deleteRelations(int $contentId, int|null $versionNo = null)

Deletes relations to and from $contentId.

If $versionNo is set only relations for that version are deleted.

Parameters

int $contentId
int|null $versionNo

at line 1254
public removeReverseFieldRelations(int $contentId)

Removes relations to Content with $contentId from Relation and RelationList field type fields.

Parameters

int $contentId

at line 1382
public deleteField(int $fieldId)

Deletes the field with the given $fieldId.

Parameters

int $fieldId

at line 1404
public deleteFields(int $contentId, int|null $versionNo = null)

Deletes all fields of $contentId in all versions.

If $versionNo is set only fields for that version are deleted.

Parameters

int $contentId
int|null $versionNo

at line 1434
public deleteVersions(int $contentId, int|null $versionNo = null)

Deletes all versions of $contentId.

If $versionNo is set only that version is deleted.

Parameters

int $contentId
int|null $versionNo

at line 1464
public deleteNames(int $contentId, int|null $versionNo = null)

Deletes all names of $contentId.

If $versionNo is set only names for that version are deleted.

Parameters

int $contentId
int|null $versionNo

at line 1495
public setName(int $contentId, int $version, string $name, string $language)

Sets the name for Content $contentId in version $version to $name in $language.

Parameters

int $contentId
int $version
string $name
string $language

at line 1609
public deleteContent(int $contentId)

Deletes the actual content object referred to by $contentId.

Parameters

int $contentId

at line 1634
public string[][] loadRelations(int $contentId, int $contentVersionNo = null, int $relationType = null)

Loads relations from $contentId to published content, optionally only from $contentVersionNo.

$relationType can also be filtered.

Parameters

int $contentId
int $contentVersionNo
int $relationType

Return Value

string[][] array of relation data

at line 1711
public mixed[][] loadReverseRelations(int $toContentId, int $relationType = null)

Loads data that related to $toContentId.

Parameters

int $toContentId
int $relationType

Return Value

mixed[][] Content data, array structured like {see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}

at line 1809
public deleteRelation(int $relationId, int $type)

Deletes the relation with the given $relationId.

Parameters

int $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 1768
public int insertRelation(CreateStruct $createStruct)

Inserts a new relation database record.

Parameters

CreateStruct $createStruct

Return Value

int ID the inserted ID

at line 1879
public int[] getContentIdsByContentTypeId(int $contentTypeId)

Returns all Content IDs for a given $contentTypeId.

Parameters

int $contentTypeId

Return Value

int[]

at line 1905
public array loadVersionedNameData(array[] $rows)

Load name data for set of content id's and corresponding version number.

Parameters

array[] $rows array of hashes with 'id' and 'version' to load names for

Return Value

array

at line 1938
public copyRelations(int $originalContentId, int $copiedContentId, int|null $versionNo = null)

Batch method for copying all relation meta data for copied Content object.

{@inheritdoc}

Parameters

int $originalContentId
int $copiedContentId
int|null $versionNo If specified only copy for a given version number, otherwise all.

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

Remove the specified translation from the Content Object Version.

Parameters

int $contentId
string $languageCode language code of the translation

Exceptions

DBALException

at line 1994
public deleteTranslatedFields(string $languageCode, int $contentId, int $versionNo = null)

Delete Content fields (attributes) for the given Translation.

If $versionNo is given, fields for that Version only will be deleted.

Parameters

string $languageCode
int $contentId
int $versionNo (optional) filter by versionNo

at line 2027
public deleteTranslationFromVersion(int $contentId, int $versionNo, string $languageCode)

Delete the specified Translation from the given Version.

Parameters

int $contentId
int $versionNo
string $languageCode

Exceptions

DBALException

at line 88
public __construct(DatabaseHandler $db, Connection $connection, QueryBuilder $queryBuilder, Handler $languageHandler, MaskGenerator $languageMaskGenerator)

Creates a new gateway based on $db.

Parameters

DatabaseHandler $db
Connection $connection
QueryBuilder $queryBuilder
Handler $languageHandler
MaskGenerator $languageMaskGenerator