DataMapProcessor

This processor analyzes the provided data-map before actually being process in the calling DataHandler instance. Field names that are configured to have "allowLanguageSynchronization" enabled are either synchronized from there relative parent records (could be a default language record, or a l10n_source record) or to their dependent records (in case a default language record or nested records pointing upwards with l10n_source).

Except inline relational record editing, all modifications are applied to the data-map directly, which ensures proper history entries as a side-effect. For inline relational record editing, this processor either triggers the copy or localize actions by instantiation a new local DataHandler instance.

Namings in this class:

  • forTableName, forId always refers to dependencies data is provided for
  • fromTableName, fromId always refers to ancestors data is retrieved from
Internal

should only be used by the TYPO3 Core

Table of Contents

Properties

$allDataMap  : array<string|int, mixed>
$allItems  : array<string|int, DataMapItem>
$backendUser  : BackendUserAuthentication
$modifiedDataMap  : array<string, array<string|int, mixed>>
$nextItems  : array<string|int, DataMapItem>
$referenceIndexUpdater  : ReferenceIndexUpdater
$sanitizationMap  : array<string, array<int, array<string|int, mixed>>>

Methods

__construct()  : mixed
instance()  : DataMapProcessor
Class generator
process()  : array<string|int, mixed>
Processes the submitted data-map and returns the sanitized and enriched version depending on accordant localization states and dependencies.
addNextItem()  : mixed
applyLocalizationReferences()  : array<string|int, mixed>
Applies localization references to given raw data-map item.
buildElementAncestorIdMap()  : array<string|int, mixed>
Builds a map from ancestor ids to accordant localization dependents.
collectItems()  : mixed
Create data map items of all affected rows
createRelationHandler()  : RelationHandler
enrich()  : mixed
Handle synchronization of an item list
fetchDependencies()  : array<string|int, array<string|int, DataMapItem>>
Fetches translation dependencies for a given parent/source record ids.
fetchDependentElements()  : array<string|int, mixed>
Fetch all elements that depend on given record id's in either their parent or source field for translatable tables or their origin field for non-translatable tables.
fetchDependentIdMap()  : array<string|int, mixed>
Fetches dependent records that depend on given record id's in in either their parent or source field for translatable tables or their origin field for non-translatable tables and creates an id mapping.
fetchTranslationValues()  : array<string|int, mixed>
Fetches translation related field values for the items submitted in the data-map.
filterItemsByType()  : array<string|int, DataMapItem>
Return array of data map items that are of given type
filterNewItemIds()  : array<string|int, mixed>
Return only ids that don't have an item equivalent in $this->allItems.
filterNumericIds()  : array<string|int, int>
Return only ids that are integer - so no "NEW..." values
findItem()  : DataMapItem|null
See if an items is in item list and return it
finishTranslationItem()  : mixed
Finishes a translation item by updating states to be persisted.
getFieldNamesForItemScope()  : array<string|int, string>
Field names we have to deal with
getFieldNamesToBeHandled()  : array<string|int, string>
Gets a list of field names which have to be handled. Basically this includes fields using allowLanguageSynchronization or l10n_mode=exclude.
getLanguageService()  : LanguageService|null
getLocalizationModeExcludeFieldNames()  : array<string|int, string>
Field names of TCA table with columns having l10n_mode=exclude
getPrefixLanguageTitleFieldNames()  : array<string|int, mixed>
Field names of TCA table with columns having l10n_mode=prefixLangTitle
isApplicable()  : bool
Determines whether the table can be localized and either has fields with allowLanguageSynchronization enabled or l10n_mode set to exclude.
isReferenceField()  : bool
True if we're dealing with a reference field (either "inline" or "file")
isRelationField()  : bool
True if we're dealing with a field that has foreign db relations
isSetInDataMap()  : bool
Determines whether a combination of table name, id and field name is set in data-map. This method considers null values as well, that would not be considered by a plain isset() invocation.
mapRelationItemId()  : array<string|int, string>
Flatten array
modifyDataMap()  : mixed
Applies modifications to the data-map, calling this method is essential to determine new data-map items to be process for synchronizing chained record localizations.
populateTranslationItem()  : mixed
Populates values downwards, either from a parent language item or a source language item to an accordant dependent translation item.
prefixLanguageTitle()  : array<string|int, mixed>
Prefixes language title if applicable for the accordant field name in raw data-map item.
purgeDataMap()  : array<string|int, mixed>
Purges superfluous empty data-map sections.
resolveAncestorId()  : int|null
resolveSuggestedInlineRelations()  : array<string|int, int>|array<string|int, string>
Determines suggest inline relations of either translation parent or source record from data-map or storage in case records have been persisted already.
sanitize()  : mixed
Sanitizes the submitted data-map items and removes fields which are not defined as custom and thus rely on either parent or source values.
sanitizeTranslationItem()  : mixed
Sanitizes the submitted data-map for a particular item and removes fields which are not defined as custom and thus rely on either parent or source values.
synchronizeDirectRelations()  : mixed
Synchronize select and group field localizations
synchronizeFieldValues()  : mixed
Synchronize simple values like text and similar
synchronizeReferences()  : mixed
Handle synchronization of references (inline or file).
synchronizeTranslationItem()  : mixed
Synchronize a single item

Properties

$allDataMap

protected array<string|int, mixed> $allDataMap = []

$modifiedDataMap

protected array<string, array<string|int, mixed>> $modifiedDataMap = []

$sanitizationMap

protected array<string, array<int, array<string|int, mixed>>> $sanitizationMap = []

Methods

instance()

Class generator

public static instance(array<string|int, mixed> $dataMap, BackendUserAuthentication $backendUser[, ReferenceIndexUpdater|null $referenceIndexUpdater = null ]) : DataMapProcessor
Parameters
$dataMap : array<string|int, mixed>

The submitted data-map to be worked on

$backendUser : BackendUserAuthentication

Forwarded backend-user scope

$referenceIndexUpdater : ReferenceIndexUpdater|null = null

Forward reference index updater to sub DataHandler instances

Return values
DataMapProcessor

process()

Processes the submitted data-map and returns the sanitized and enriched version depending on accordant localization states and dependencies.

public process() : array<string|int, mixed>
Return values
array<string|int, mixed>

applyLocalizationReferences()

Applies localization references to given raw data-map item.

protected applyLocalizationReferences(string $tableName, string|int $fromId, int $language, array<string|int, mixed> $fieldNames, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$tableName : string
$fromId : string|int
$language : int
$fieldNames : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

buildElementAncestorIdMap()

Builds a map from ancestor ids to accordant localization dependents.

protected buildElementAncestorIdMap(array<string|int, mixed> $fieldNames, array<string|int, mixed> $elements) : array<string|int, mixed>

The result of e.g. [5 => [6, 7]] refers to ids 6 and 7 being dependents (either used in parent or source field) of the ancestor with id 5.

Parameters
$fieldNames : array<string|int, mixed>
$elements : array<string|int, mixed>
Return values
array<string|int, mixed>

collectItems()

Create data map items of all affected rows

protected collectItems(string $tableName, array<string|int, mixed> $idValues) : mixed
Parameters
$tableName : string
$idValues : array<string|int, mixed>

enrich()

Handle synchronization of an item list

protected enrich(array<string|int, DataMapItem$items) : mixed
Parameters
$items : array<string|int, DataMapItem>

fetchDependencies()

Fetches translation dependencies for a given parent/source record ids.

protected fetchDependencies(string $tableName, array<string|int, int>|array<string|int, string> $ids) : array<string|int, array<string|int, DataMapItem>>

Existing records in database:

  • [uid:5, l10n_parent=0, l10n_source=0, sys_language_uid=0]
  • [uid:6, l10n_parent=5, l10n_source=5, sys_language_uid=1]
  • [uid:7, l10n_parent=5, l10n_source=6, sys_language_uid=2]

Input $ids and their results:

  • [5] -> [DataMapItem(6), DataMapItem(7)] # since 5 is parent/source
  • [6] -> [DataMapItem(7)] # since 6 is source
  • [7] -> [] # since there's nothing
Parameters
$tableName : string
$ids : array<string|int, int>|array<string|int, string>
Return values
array<string|int, array<string|int, DataMapItem>>

fetchDependentElements()

Fetch all elements that depend on given record id's in either their parent or source field for translatable tables or their origin field for non-translatable tables.

protected fetchDependentElements(string $tableName, array<string|int, mixed> $ids, array<string|int, mixed> $fieldNames) : array<string|int, mixed>
Parameters
$tableName : string
$ids : array<string|int, mixed>
$fieldNames : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

fetchDependentIdMap()

Fetches dependent records that depend on given record id's in in either their parent or source field for translatable tables or their origin field for non-translatable tables and creates an id mapping.

protected fetchDependentIdMap(string $tableName, array<string|int, mixed> $ids, int $desiredLanguage) : array<string|int, mixed>

This method expands the search criteria by expanding to ancestors.

Existing records in database:

  • [uid:5, l10n_parent=0, l10n_source=0, sys_language_uid=0]
  • [uid:6, l10n_parent=5, l10n_source=5, sys_language_uid=1]
  • [uid:7, l10n_parent=5, l10n_source=6, sys_language_uid=2]

Input $ids and $desiredLanguage and their results:

  • $ids=[5], $lang=1 -> [5 => 6] # since 5 is source of 6
  • $ids=[5], $lang=2 -> [] # since 5 is parent of 7, but different language
  • $ids=[6], $lang=1 -> [] # since there's nothing
  • $ids=[6], $lang=2 -> [6 => 7] # since 6 has source 5, which is ancestor of 7
  • $ids=[7], $lang=* -> [] # since there's nothing
Parameters
$tableName : string
$ids : array<string|int, mixed>
$desiredLanguage : int
Return values
array<string|int, mixed>

fetchTranslationValues()

Fetches translation related field values for the items submitted in the data-map.

protected fetchTranslationValues(string $tableName, array<string|int, mixed> $fieldNames, array<string|int, mixed> $ids) : array<string|int, mixed>
Parameters
$tableName : string
$fieldNames : array<string|int, mixed>
$ids : array<string|int, mixed>
Return values
array<string|int, mixed>

filterItemsByType()

Return array of data map items that are of given type

protected filterItemsByType(string $type, array<string|int, DataMapItem$items) : array<string|int, DataMapItem>
Parameters
$type : string
$items : array<string|int, DataMapItem>
Return values
array<string|int, DataMapItem>

filterNewItemIds()

Return only ids that don't have an item equivalent in $this->allItems.

protected filterNewItemIds(string $tableName, array<string|int, int> $ids) : array<string|int, mixed>
Parameters
$tableName : string
$ids : array<string|int, int>
Return values
array<string|int, mixed>

filterNumericIds()

Return only ids that are integer - so no "NEW..." values

protected filterNumericIds(array<string|int, string>|array<string|int, int> $ids) : array<string|int, int>
Parameters
$ids : array<string|int, string>|array<string|int, int>
Return values
array<string|int, int>

findItem()

See if an items is in item list and return it

protected findItem(string $tableName, string|int $id) : DataMapItem|null
Parameters
$tableName : string
$id : string|int
Return values
DataMapItem|null

finishTranslationItem()

Finishes a translation item by updating states to be persisted.

protected finishTranslationItem(DataMapItem $item) : mixed
Parameters
$item : DataMapItem

getFieldNamesForItemScope()

Field names we have to deal with

protected getFieldNamesForItemScope(DataMapItem $item, string $scope, bool $modified) : array<string|int, string>
Parameters
$item : DataMapItem
$scope : string
$modified : bool
Return values
array<string|int, string>

getFieldNamesToBeHandled()

Gets a list of field names which have to be handled. Basically this includes fields using allowLanguageSynchronization or l10n_mode=exclude.

protected getFieldNamesToBeHandled(string $tableName) : array<string|int, string>
Parameters
$tableName : string
Return values
array<string|int, string>

getLocalizationModeExcludeFieldNames()

Field names of TCA table with columns having l10n_mode=exclude

protected getLocalizationModeExcludeFieldNames(string $tableName) : array<string|int, string>
Parameters
$tableName : string
Return values
array<string|int, string>

getPrefixLanguageTitleFieldNames()

Field names of TCA table with columns having l10n_mode=prefixLangTitle

protected getPrefixLanguageTitleFieldNames(string $tableName) : array<string|int, mixed>
Parameters
$tableName : string
Return values
array<string|int, mixed>

isApplicable()

Determines whether the table can be localized and either has fields with allowLanguageSynchronization enabled or l10n_mode set to exclude.

protected isApplicable(string $tableName) : bool
Parameters
$tableName : string
Return values
bool

isReferenceField()

True if we're dealing with a reference field (either "inline" or "file")

protected isReferenceField(string $tableName, string $fieldName) : bool
Parameters
$tableName : string
$fieldName : string
Return values
bool

TRUE if field is of type inline with foreign_table set

isRelationField()

True if we're dealing with a field that has foreign db relations

protected isRelationField(string $tableName, string $fieldName) : bool
Parameters
$tableName : string
$fieldName : string
Return values
bool

True if field is type=group or select with foreign_table

isSetInDataMap()

Determines whether a combination of table name, id and field name is set in data-map. This method considers null values as well, that would not be considered by a plain isset() invocation.

protected isSetInDataMap(string $tableName, string|int $id, string $fieldName) : bool
Parameters
$tableName : string
$id : string|int
$fieldName : string
Return values
bool

mapRelationItemId()

Flatten array

protected mapRelationItemId(array<string|int, mixed> $relationItems) : array<string|int, string>
Parameters
$relationItems : array<string|int, mixed>
Return values
array<string|int, string>

modifyDataMap()

Applies modifications to the data-map, calling this method is essential to determine new data-map items to be process for synchronizing chained record localizations.

protected modifyDataMap(string $tableName, string|int $id, array<string|int, mixed> $values) : mixed
Parameters
$tableName : string
$id : string|int
$values : array<string|int, mixed>
Tags
throws
RuntimeException

populateTranslationItem()

Populates values downwards, either from a parent language item or a source language item to an accordant dependent translation item.

protected populateTranslationItem(DataMapItem $item) : mixed
Parameters
$item : DataMapItem

prefixLanguageTitle()

Prefixes language title if applicable for the accordant field name in raw data-map item.

protected prefixLanguageTitle(string $tableName, string|int $fromId, int $language, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$tableName : string
$fromId : string|int
$language : int
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

purgeDataMap()

Purges superfluous empty data-map sections.

protected purgeDataMap(array<string|int, mixed> $dataMap) : array<string|int, mixed>
Parameters
$dataMap : array<string|int, mixed>
Return values
array<string|int, mixed>

resolveAncestorId()

protected resolveAncestorId(array<string, string> $fieldNames, array<string, mixed> $element) : int|null
Parameters
$fieldNames : array<string, string>
$element : array<string, mixed>
Return values
int|null

either a (non-empty) ancestor uid, or null if unresolved

resolveSuggestedInlineRelations()

Determines suggest inline relations of either translation parent or source record from data-map or storage in case records have been persisted already.

protected resolveSuggestedInlineRelations(DataMapItem $item, string $fieldName, array<string|int, mixed> $fromRecord) : array<string|int, int>|array<string|int, string>
Parameters
$item : DataMapItem
$fieldName : string
$fromRecord : array<string|int, mixed>
Return values
array<string|int, int>|array<string|int, string>

sanitize()

Sanitizes the submitted data-map items and removes fields which are not defined as custom and thus rely on either parent or source values.

protected sanitize(array<string|int, DataMapItem$items) : mixed
Parameters
$items : array<string|int, DataMapItem>

sanitizeTranslationItem()

Sanitizes the submitted data-map for a particular item and removes fields which are not defined as custom and thus rely on either parent or source values.

protected sanitizeTranslationItem(DataMapItem $item) : mixed
Parameters
$item : DataMapItem

synchronizeDirectRelations()

Synchronize select and group field localizations

protected synchronizeDirectRelations(DataMapItem $item, string $fieldName, array<string|int, mixed> $fromRecord) : mixed
Parameters
$item : DataMapItem
$fieldName : string
$fromRecord : array<string|int, mixed>

synchronizeFieldValues()

Synchronize simple values like text and similar

protected synchronizeFieldValues(DataMapItem $item, string $fieldName, array<string|int, mixed> $fromRecord, array<string|int, mixed> $forRecord) : mixed
Parameters
$item : DataMapItem
$fieldName : string
$fromRecord : array<string|int, mixed>
$forRecord : array<string|int, mixed>

synchronizeReferences()

Handle synchronization of references (inline or file).

protected synchronizeReferences(DataMapItem $item, string $fieldName, array<string|int, mixed> $fromRecord, array<string|int, mixed> $forRecord) : mixed

References are always modelled as 1:n composite relation - which means that direct(!) children cannot exist without their parent. Removing a relative parent results in cascaded removal of all direct(!) children as well.

Parameters
$item : DataMapItem
$fieldName : string
$fromRecord : array<string|int, mixed>
$forRecord : array<string|int, mixed>
Tags
throws
RuntimeException

synchronizeTranslationItem()

Synchronize a single item

protected synchronizeTranslationItem(DataMapItem $item, array<string|int, mixed> $fieldNames, string|int $fromId) : mixed
Parameters
$item : DataMapItem
$fieldNames : array<string|int, mixed>
$fromId : string|int

        
On this page

Search results