eZPublishCommunityProject  2013.9
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase Class Reference

ezcDatabase based content gateway More...

+ Inheritance diagram for eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase:
+ Collaboration diagram for eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase:

Public Member Functions

 __construct (EzcDbHandler $db, QueryBuilder $queryBuilder, LanguageHandler $languageHandler, LanguageMaskGenerator $languageMaskGenerator)
 Creates a new gateway based on $db. More...
 
 deleteContent ($contentId)
 Deletes the actual content object referred to by $contentId. More...
 
 deleteField ($fieldId)
 Deletes the field with the given $fieldId. More...
 
 deleteFields ($contentId, $versionNo=null)
 Deletes all fields of $contentId in all versions. More...
 
 deleteNames ($contentId, $versionNo=null)
 Deletes all names of $contentId. More...
 
 deleteRelations ($contentId, $versionNo=null)
 Deletes relations to and from $contentId. More...
 
 deleteVersions ($contentId, $versionNo=null)
 Deletes all versions of $contentId. More...
 
 getAllLocationIds ($contentId)
 Returns all IDs for locations that refer to $contentId. More...
 
 getContext ()
 Get context definition for external storage layers. More...
 
 getFieldIdsByType ($contentId, $versionNo=null)
 Returns all field IDs of $contentId grouped by their type. More...
 
 getLastVersionNumber ($contentId)
 Returns last version number for content identified by $contentId. More...
 
 insertContentObject (CreateStruct $struct, $currentVersionNo=1)
 Inserts a new content object. More...
 
 insertExistingField (Content $content, Field $field, StorageFieldValue $value)
 Inserts an existing field. More...
 
 insertNewField (Content $content, Field $field, StorageFieldValue $value)
 Inserts a new field. More...
 
 insertRelation (RelationCreateStruct $createStruct)
 Inserts a new relation database record. More...
 
 listVersionNumbers ($contentId)
 Returns all version numbers for the given $contentId. More...
 
 listVersions ($contentId)
 Returns all version data for the given $contentId. More...
 
 listVersionsForUser ($userId, $status=VersionInfo::STATUS_DRAFT)
 Returns data for all versions with given status created by the given $userId. More...
 
 load ($contentId, $version, $translations=null)
 Loads data for a content object. More...
 
 loadContentInfo ($contentId)
 Loads info for content identified by $contentId. More...
 
 loadContentInfoByRemoteId ($remoteId)
 Loads info for a content object identified by its remote ID. More...
 
 loadLatestPublishedData ($contentId)
 Loads data for the latest published version of the content identified by $contentId. More...
 
 loadRelations ($contentId, $contentVersionNo=null, $relationType=null)
 Loads relations from $contentId to published content, optionally only from $contentVersionNo. More...
 
 loadReverseRelations ($toContentId, $relationType=null)
 Loads data that related to $toContentId. More...
 
 loadVersionInfo ($contentId, $versionNo)
 Loads version info for content identified by $contentId and $versionNo. More...
 
 setName ($contentId, $version, $name, $language)
 Sets the name for Content $contentId in version $version to $name in $language. More...
 
 setStatus ($contentId, $version, $status)
 Sets the status of the version identified by $contentId and $version to $status. More...
 
 updateContent ($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo=null)
 Updates an existing content identified by $contentId in respect to $struct. More...
 
 updateField (Field $field, StorageFieldValue $value)
 Updates an existing field. More...
 
 updateNonTranslatableField (Field $field, StorageFieldValue $value, $contentId)
 Updates an existing, non-translatable field. More...
 
 updateVersion ($contentId, $versionNo, UpdateStruct $struct)
 Updates version $versionNo for content identified by $contentId, in respect to $struct. More...
 
- Public Member Functions inherited from eZ\Publish\Core\Persistence\Legacy\Content\Gateway
 deleteContent ($contentId)
 Deletes the actual content object referred to by $contentId. More...
 
 deleteField ($fieldId)
 Deletes the field with the given $fieldId. More...
 
 deleteFields ($contentId, $versionNo=null)
 Deletes all fields of $contentId in all versions. More...
 
 deleteNames ($contentId, $versionNo=null)
 Deletes all names of $contentId. More...
 
 deleteRelation ($relationId, $type)
 Deletes the relation with the given $relationId. More...
 
 deleteRelations ($contentId, $versionNo=null)
 Deletes relations to and from $contentId. More...
 
 deleteVersions ($contentId, $versionNo=null)
 Deletes all versions of $contentId. More...
 
 getAllLocationIds ($contentId)
 Returns all IDs for locations that refer to $contentId. More...
 
 getContext ()
 Get context definition for external storage layers. More...
 
 getFieldIdsByType ($contentId, $versionNo=null)
 Returns all field IDs of $contentId grouped by their type. More...
 
 getLastVersionNumber ($contentId)
 Returns last version number for content identified by $contentId. More...
 
 insertContentObject (CreateStruct $struct, $currentVersionNo=1)
 Inserts a new content object. More...
 
 insertExistingField (Content $content, Field $field, StorageFieldValue $value)
 Inserts an existing field. More...
 
 insertNewField (Content $content, Field $field, StorageFieldValue $value)
 Inserts a new field. More...
 
 insertRelation (RelationCreateStruct $createStruct)
 Inserts a new relation database record. More...
 
 insertVersion (VersionInfo $versionInfo, array $fields)
 Inserts a new version. More...
 
 listVersionNumbers ($contentId)
 Returns all version numbers for the given $contentId. More...
 
 listVersions ($contentId)
 Returns all version data for the given $contentId. More...
 
 listVersionsForUser ($userId, $status=VersionInfo::STATUS_DRAFT)
 Returns data for all versions with given status created by the given $userId. More...
 
 load ($contentId, $version, $translations=null)
 Loads data for a content object. More...
 
 loadContentInfo ($contentId)
 Loads info for content identified by $contentId. More...
 
 loadContentInfoByRemoteId ($remoteId)
 Loads info for a content object identified by its remote ID. More...
 
 loadLatestPublishedData ($contentId)
 Loads data for the latest published version of the content identified by $contentId. More...
 
 loadRelations ($contentId, $contentVersionNo=null, $relationType=null)
 Loads data of related to/from $contentId. More...
 
 loadReverseRelations ($contentId, $relationType=null)
 Loads data of related to/from $contentId. More...
 
 loadVersionInfo ($contentId, $versionNo)
 Loads version info for content identified by $contentId and $versionNo. More...
 
 setName ($contentId, $version, $name, $language)
 Sets the content object name. More...
 
 setStatus ($contentId, $version, $status)
 Sets the state of object identified by $contentId and $version to $state. More...
 
 updateAlwaysAvailableFlag ($contentId, $newAlwaysAvailable)
 Updates "always available" flag for content identified by $contentId, in respect to $alwaysAvailable. More...
 
 updateContent ($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo=null)
 Updates an existing content identified by $contentId in respect to $struct. More...
 
 updateField (Field $field, StorageFieldValue $value)
 Updates an existing field. More...
 
 updateNonTranslatableField (Field $field, StorageFieldValue $value, $contentId)
 Updates an existing, non-translatable field. More...
 
 updateVersion ($contentId, $versionNo, UpdateStruct $struct)
 Updates version $versionNo for content identified by $contentId, in respect to $struct. More...
 

Protected Member Functions

 generateLanguageMask (array $fields, $initialLanguageCode, $alwaysAvailable)
 Generates a language mask for $version. More...
 
 setFieldUpdateValues (ezcQueryUpdate $q, StorageFieldValue $value)
 Sets update fields for $value on $q. More...
 
 setInsertFieldValues (\ezcQueryInsert $q, Content $content, Field $field, StorageFieldValue $value)
 Inserts $field with $newFieldId or not. More...
 

Protected Attributes

 $dbHandler
 
 $languageHandler
 
 $languageMaskGenerator
 
 $queryBuilder
 

Private Member Functions

 listVersionsHelper ($query)
 Helper for {. More...
 

Detailed Description

ezcDatabase based content gateway

Constructor & Destructor Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::__construct ( EzcDbHandler  $db,
QueryBuilder  $queryBuilder,
LanguageHandler  $languageHandler,
LanguageMaskGenerator  $languageMaskGenerator 
)

Creates a new gateway based on $db.

Parameters
\eZ\Publish\Core\Persistence\Legacy\EzcDbHandler$db
\eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\QueryBuilder$queryBuilder
\eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler$languageHandler
\eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator$languageMaskGenerator

Member Function Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteContent (   $contentId)

Deletes the actual content object referred to by $contentId.

Parameters
int$contentId
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteField (   $fieldId)

Deletes the field with the given $fieldId.

Parameters
int$fieldId
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteFields (   $contentId,
  $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
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteNames (   $contentId,
  $versionNo = null 
)

Deletes all names of $contentId.

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

Parameters
int$contentId
int | null$versionNo
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteRelations (   $contentId,
  $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
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::deleteVersions (   $contentId,
  $versionNo = null 
)

Deletes all versions of $contentId.

If $versionNo is set only that version is deleted.

Parameters
int$contentId
int | null$versionNo
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::generateLanguageMask ( array  $fields,
  $initialLanguageCode,
  $alwaysAvailable 
)
protected

Generates a language mask for $version.

Parameters
\eZ\Publish\SPI\Persistence\Content\Field[]$fields
string$initialLanguageCode
boolean$alwaysAvailable
Returns
int

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\insertContentObject(), and eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\updateVersion().

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::getAllLocationIds (   $contentId)

Returns all IDs for locations that refer to $contentId.

Parameters
int$contentId
Returns
int[]
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::getContext ( )

Get context definition for external storage layers.

Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::getFieldIdsByType (   $contentId,
  $versionNo = null 
)

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

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

Parameters
int$contentId
int | null$versionNo
Returns
int[][]
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::getLastVersionNumber (   $contentId)

Returns last version number for content identified by $contentId.

Parameters
int$contentId
Returns
int
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::insertContentObject ( CreateStruct  $struct,
  $currentVersionNo = 1 
)

Inserts a new content object.

Parameters
\eZ\Publish\SPI\Persistence\Content\CreateStruct$struct
mixed$currentVersionNo
Returns
int ID
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::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
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::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
\eZ\Publish\SPI\Persistence\Content$content
\eZ\Publish\SPI\Persistence\Content\Field$field
\eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue$value
Returns
int ID
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::insertRelation ( RelationCreateStruct  $createStruct)

Inserts a new relation database record.

Parameters
\eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct$createStruct
Returns
int ID the inserted ID
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::listVersionNumbers (   $contentId)

Returns all version numbers for the given $contentId.

Parameters
mixed$contentId
Returns
int[]
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::listVersions (   $contentId)

Returns all version data for the given $contentId.

Parameters
mixed$contentId
Returns
string[][]
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::listVersionsForUser (   $userId,
  $status = VersionInfo::STATUS_DRAFT 
)

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

Parameters
int$userId
int$status
Returns
string[][]
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::listVersionsHelper (   $query)
private

Helper for {.

See Also
listVersions()} and {
listVersionsForUser()} that filters duplicates that are the result of the cartesian product performed by createVersionInfoFindQuery()
Parameters
\ezcQuerySelect$query
Returns
string[][]

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\listVersions(), and eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\listVersionsForUser().

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::load (   $contentId,
  $version,
  $translations = null 
)

Loads data for a content object.

Returns an array with the relevant data.

Parameters
mixed$contentId
mixed$version
string[]$translations
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadContentInfo (   $contentId)

Loads info for content identified by $contentId.

Will basically return a hash containing all field values for ezcontentobject table plus some additional keys:

  • always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field
  • main_language_code => Language code for main (initial) language. E.g. "eng-GB"
Parameters
int$contentId
Exceptions
\eZ\Publish\Core\Base\Exceptions\NotFoundException
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadContentInfoByRemoteId (   $remoteId)

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

Returns an array with the relevant data.

Parameters
mixed$remoteId
Exceptions
\eZ\Publish\Core\Base\Exceptions\NotFoundException
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadLatestPublishedData (   $contentId)

Loads data for the latest published version of the content identified by $contentId.

Parameters
mixed$contentId
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadRelations (   $contentId,
  $contentVersionNo = null,
  $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
Returns
string[][] array of relation data
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadReverseRelations (   $toContentId,
  $relationType = null 
)

Loads data that related to $toContentId.

Parameters
int$toContentId
int$relationType
Returns
mixed[][] Content data, array structured like {
See Also
::load()}
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::loadVersionInfo (   $contentId,
  $versionNo 
)

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

Will basically return a hash containing all field values from ezcontentobject_version 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.
  • initial_language_code => Language code for initial language in this version.
Parameters
int$contentId
int$versionNo
Returns
array
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::setFieldUpdateValues ( ezcQueryUpdate  $q,
StorageFieldValue  $value 
)
protected
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::setInsertFieldValues ( \ezcQueryInsert  $q,
Content  $content,
Field  $field,
StorageFieldValue  $value 
)
protected

Inserts $field with $newFieldId or not.

Parameters
Content$content
Field$field
StorageFieldValue$value
mixed$newFieldId
Returns
int|null Maybe a new field ID

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\insertExistingField(), and eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase\insertNewField().

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::setName (   $contentId,
  $version,
  $name,
  $language 
)

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

Parameters
int$contentId
int$version
string$name
string$language
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::setStatus (   $contentId,
  $version,
  $status 
)

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

The $status can be one of STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED

Parameters
int$contentId
int$version
int$status
Returns
boolean
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::updateContent (   $contentId,
MetadataUpdateStruct  $struct,
VersionInfo  $prePublishVersionInfo = null 
)

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

Parameters
int$contentId
\eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct$struct
\eZ\Publish\SPI\Persistence\Content\VersionInfo$prePublishVersionInfoProvided on publish
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::updateField ( Field  $field,
StorageFieldValue  $value 
)

Updates an existing field.

Parameters
Field$field
StorageFieldValue$value
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::updateNonTranslatableField ( Field  $field,
StorageFieldValue  $value,
  $contentId 
)

Updates an existing, non-translatable field.

Parameters
\eZ\Publish\SPI\Persistence\Content\Field$field
\eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue$value
int$contentId
Returns
void
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::updateVersion (   $contentId,
  $versionNo,
UpdateStruct  $struct 
)

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

Parameters
int$contentId
int$versionNo
\eZ\Publish\SPI\Persistence\Content\UpdateStruct$struct
Returns
void

Member Data Documentation

eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::$dbHandler
protected
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::$languageHandler
protected
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::$languageMaskGenerator
protected
eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase::$queryBuilder
protected

The documentation for this class was generated from the following file: