Class

eZ\Publish\Core\Repository\Helper\DomainMapper

class DomainMapper

DomainMapper is an internal service.

Constants

MAX_LOCATION_PRIORITY

MIN_LOCATION_PRIORITY

Methods

__construct(Handler $contentHandler, Handler $locationHandler, Handler $contentTypeHandler, Handler $contentLanguageHandler, FieldTypeRegistry $fieldTypeRegistry)

Setups service with reference to repository.

Content buildContentDomainObject(Content $spiContent, ContentType|Type $contentType = null, array $fieldLanguages = null, string|null $fieldAlwaysAvailableLanguage = null)

Builds a Content domain object from value object returned from persistence.

array buildDomainFields(array $spiFields, ContentType|Type $contentType, array $languages = null, string|null $alwaysAvailableLanguage = null)

Returns an array of domain fields created from given array of SPI fields.

VersionInfo buildVersionInfoDomainObject(VersionInfo $spiVersionInfo, array $prioritizedLanguages = array())

Builds a VersionInfo domain object from value object returned from persistence.

ContentInfo buildContentInfoDomainObject(ContentInfo $spiContentInfo)

Builds a ContentInfo domain object from value object returned from persistence.

Relation buildRelationDomainObject(Relation $spiRelation, ContentInfo $sourceContentInfo, ContentInfo $destinationContentInfo)

Builds API Relation object from provided SPI Relation object.

Location buildLocationDomainObject(Location $spiLocation, ContentInfo $contentInfo = null)

Builds domain location object from provided persistence location.

Location[] buildLocationDomainObjectsOnSearchResult(SearchResult $result)

Build API Location and corresponding ContentInfo domain objects and apply to LocationSearchResult.

CreateStruct buildSPILocationCreateStruct(LocationCreateStruct $locationCreateStruct, Location $parentLocation, mixed $mainLocation, mixed $contentId, mixed $contentVersionNo)

Creates an array of SPI location create structs from given array of API location create structs.

bool isValidLocationSortField(mixed $sortField)

Checks if given $sortField value is one of the defined sort field constants.

bool isValidLocationSortOrder(mixed $sortOrder)

Checks if given $sortOrder value is one of the defined sort order constants.

bool isValidLocationPriority(int $priority)

Checks if given $priority is valid.

validateTranslatedList(mixed $list, string $argumentName)

Validates given translated list $list, which should be an array of strings with language codes as keys.

DateTime getDateTime(int $timestamp)

Returns \DateTime object from given $timestamp in environment timezone.

string getUniqueHash(object $object)

Creates unique hash string for given $object.

Details

at line 82
public __construct(Handler $contentHandler, Handler $locationHandler, Handler $contentTypeHandler, Handler $contentLanguageHandler, FieldTypeRegistry $fieldTypeRegistry)

Setups service with reference to repository.

Parameters

Handler $contentHandler
Handler $locationHandler
Handler $contentTypeHandler
Handler $contentLanguageHandler
FieldTypeRegistry $fieldTypeRegistry

at line 106
public Content buildContentDomainObject(Content $spiContent, ContentType|Type $contentType = null, array $fieldLanguages = null, string|null $fieldAlwaysAvailableLanguage = null)

Builds a Content domain object from value object returned from persistence.

Parameters

Content $spiContent
ContentType|Type $contentType
array $fieldLanguages Language codes to filter fields on
string|null $fieldAlwaysAvailableLanguage Language code fallback if a given field is not found in $fieldLanguages

Return Value

Content

at line 148
public array buildDomainFields(array $spiFields, ContentType|Type $contentType, array $languages = null, string|null $alwaysAvailableLanguage = null)

Returns an array of domain fields created from given array of SPI fields.

Parameters

array $spiFields
ContentType|Type $contentType
array $languages A language priority, filters returned fields and is used as prioritized language code on returned value object. If not given all languages are returned.
string|null $alwaysAvailableLanguage Language code fallback if a given field is not found in $languages

Return Value

array

Exceptions

InvalidArgumentType On invalid $contentType

at line 212
public VersionInfo buildVersionInfoDomainObject(VersionInfo $spiVersionInfo, array $prioritizedLanguages = array())

Builds a VersionInfo domain object from value object returned from persistence.

Parameters

VersionInfo $spiVersionInfo
array $prioritizedLanguages

Return Value

VersionInfo

at line 262
public ContentInfo buildContentInfoDomainObject(ContentInfo $spiContentInfo)

Builds a ContentInfo domain object from value object returned from persistence.

Parameters

ContentInfo $spiContentInfo

Return Value

ContentInfo

at line 296
public Relation buildRelationDomainObject(Relation $spiRelation, ContentInfo $sourceContentInfo, ContentInfo $destinationContentInfo)

Builds API Relation object from provided SPI Relation object.

Parameters

Relation $spiRelation
ContentInfo $sourceContentInfo
ContentInfo $destinationContentInfo

Return Value

Relation

at line 333
public Location buildLocationDomainObject(Location $spiLocation, ContentInfo $contentInfo = null)

Builds domain location object from provided persistence location.

Parameters

Location $spiLocation
ContentInfo $contentInfo

Return Value

Location

at line 387
public Location[] buildLocationDomainObjectsOnSearchResult(SearchResult $result)

Build API Location and corresponding ContentInfo domain objects and apply to LocationSearchResult.

Loading of ContentInfo objects are done in one operation.

Parameters

SearchResult $result SPI search result with SPI Location items as hits

Return Value

Location[] Locations we did not find content info for is retunred as an array.

at line 425
public CreateStruct buildSPILocationCreateStruct(LocationCreateStruct $locationCreateStruct, Location $parentLocation, mixed $mainLocation, mixed $contentId, mixed $contentVersionNo)

Creates an array of SPI location create structs from given array of API location create structs.

Parameters

LocationCreateStruct $locationCreateStruct
Location $parentLocation
mixed $mainLocation
mixed $contentId
mixed $contentVersionNo

Return Value

CreateStruct

Exceptions

InvalidArgumentException

at line 496
public bool isValidLocationSortField(mixed $sortField)

Checks if given $sortField value is one of the defined sort field constants.

Parameters

mixed $sortField

Return Value

bool

at line 524
public bool isValidLocationSortOrder(mixed $sortOrder)

Checks if given $sortOrder value is one of the defined sort order constants.

Parameters

mixed $sortOrder

Return Value

bool

at line 542
public bool isValidLocationPriority(int $priority)

Checks if given $priority is valid.

Parameters

int $priority

Return Value

bool

at line 559
public validateTranslatedList(mixed $list, string $argumentName)

Validates given translated list $list, which should be an array of strings with language codes as keys.

Parameters

mixed $list
string $argumentName

Exceptions

InvalidArgumentException

at line 584
public DateTime getDateTime(int $timestamp)

Returns \DateTime object from given $timestamp in environment timezone.

This method is needed because constructing \DateTime with $timestamp will return the object in UTC timezone.

Parameters

int $timestamp

Return Value

DateTime

at line 601
public string getUniqueHash(object $object)

Creates unique hash string for given $object.

Used for remoteId.

Parameters

object $object

Return Value

string