‪TYPO3CMS  ‪main
TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor Class Reference

Public Member Functions

array process ()
 

Public Attributes

$this backendUser = $backendUser
 
if($referenceIndexUpdater===null) $this referenceIndexUpdater = $referenceIndexUpdater
 

Protected Member Functions

 purgeDataMap (array $dataMap)
 
 collectItems (string $tableName, array $idValues)
 
 sanitize (array $items)
 
 enrich (array $items)
 
 sanitizeTranslationItem (DataMapItem $item)
 
 synchronizeTranslationItem (DataMapItem $item, array $fieldNames, $fromId)
 
 populateTranslationItem (DataMapItem $item)
 
 finishTranslationItem (DataMapItem $item)
 
 synchronizeFieldValues (DataMapItem $item, string $fieldName, array $fromRecord, array $forRecord)
 
 synchronizeDirectRelations (DataMapItem $item, string $fieldName, array $fromRecord)
 
 synchronizeReferences (DataMapItem $item, string $fieldName, array $fromRecord, array $forRecord)
 
int[] string[] resolveSuggestedInlineRelations (DataMapItem $item, string $fieldName, array $fromRecord)
 
bool isSetInDataMap (string $tableName, $id, string $fieldName)
 
 modifyDataMap (string $tableName, $id, array $values)
 
 addNextItem (DataMapItem $item)
 
array fetchTranslationValues (string $tableName, array $fieldNames, array $ids)
 
DataMapItem[][] fetchDependencies (string $tableName, array $ids)
 
array fetchDependentIdMap (string $tableName, array $ids, int $desiredLanguage)
 
array fetchDependentElements (string $tableName, array $ids, array $fieldNames)
 
DataMapItem[] filterItemsByType (string $type, array $items)
 
int[] filterNumericIds (array $ids)
 
array filterNewItemIds (string $tableName, array $ids)
 
int[] mapRelationItemId (array $relationItems)
 
int null resolveAncestorId (array $fieldNames, array $element)
 
array buildElementAncestorIdMap (array $fieldNames, array $elements)
 
DataMapItem null findItem (string $tableName, $id)
 
 applyLocalizationReferences (string $tableName, $fromId, int $language, array $fieldNames, array $data)
 
 prefixLanguageTitle (string $tableName, $fromId, int $language, array $data)
 
string[] getFieldNamesForItemScope (DataMapItem $item, string $scope, bool $modified)
 
string[] getLocalizationModeExcludeFieldNames (string $tableName)
 
string[] getFieldNamesToBeHandled (string $tableName)
 
array getPrefixLanguageTitleFieldNames (string $tableName)
 
bool isRelationField (string $tableName, string $fieldName)
 
bool isReferenceField (string $tableName, string $fieldName)
 
 isApplicable (string $tableName)
 
RelationHandler createRelationHandler ()
 
 getLanguageService ()
 

Protected Attributes

array $allDataMap = array( )
 
array< string, $modifiedDataMap=array();protected array< string, $sanitizationMap=array();protected BackendUserAuthentication $backendUser;protected ReferenceIndexUpdater $referenceIndexUpdater;protected DataMapItem[] $allItems=array();protected DataMapItem[] $nextItems=array();public static DataMapProcessor function instance(array $dataMap, BackendUserAuthentication $backendUser, ReferenceIndexUpdater $referenceIndexUpdater=null) { return GeneralUtility::makeInstance(static::class, $dataMap, $backendUser, $referenceIndexUpdater);} public function __construct(array $dataMap, BackendUserAuthentication $backendUser, ReferenceIndexUpdater $referenceIndexUpdater=null) { $this->allDataMap=$dataMap;$this-> modifiedDataMap = $dataMap
 

Private Member Functions

int[] resolvePersistedInlineRelations (DataMapItem $item, string $fieldName, array $forRecord)
 

Detailed Description

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

should only be used by the TYPO3 Core

Definition at line 58 of file DataMapProcessor.php.

Member Function Documentation

◆ addNextItem()

◆ applyLocalizationReferences()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::applyLocalizationReferences ( string  $tableName,
  $fromId,
int  $language,
array  $fieldNames,
array  $data 
)
protected

Applies localization references to given raw data-map item.

Parameters
string | int$fromId

Definition at line 1261 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\getFieldNamesToBeHandled().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeReferences().

◆ buildElementAncestorIdMap()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::buildElementAncestorIdMap ( array  $fieldNames,
array  $elements 
)
protected

Builds a map from ancestor ids to accordant localization dependents.

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
array$fieldNames
array$elements
Returns
‪array

Definition at line 1233 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolveAncestorId().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchDependentIdMap().

◆ collectItems()

◆ createRelationHandler()

◆ enrich()

◆ fetchDependencies()

DataMapItem [][] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::fetchDependencies ( string  $tableName,
array  $ids 
)
protected

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

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
string$tableName
int[] | string[]$ids
Returns
DataMapItem[][]

Definition at line 903 of file DataMapProcessor.php.

References $GLOBALS, TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\build(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchDependentElements(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterNumericIds(), TYPO3\CMS\Core\DataHandling\Localization\State\STATE_PARENT, and TYPO3\CMS\Core\DataHandling\Localization\State\STATE_SOURCE.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\collectItems().

◆ fetchDependentElements()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::fetchDependentElements ( string  $tableName,
array  $ids,
array  $fieldNames 
)
protected

◆ fetchDependentIdMap()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::fetchDependentIdMap ( string  $tableName,
array  $ids,
int  $desiredLanguage 
)
protected

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.

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
string$tableName
array$ids
int$desiredLanguage
Returns
‪array

Definition at line 980 of file DataMapProcessor.php.

References $GLOBALS, TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\buildElementAncestorIdMap(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchDependentElements(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchTranslationValues(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterNumericIds(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolveAncestorId().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeReferences().

◆ fetchTranslationValues()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::fetchTranslationValues ( string  $tableName,
array  $fieldNames,
array  $ids 
)
protected

◆ filterItemsByType()

DataMapItem [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::filterItemsByType ( string  $type,
array  $items 
)
protected

◆ filterNewItemIds()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::filterNewItemIds ( string  $tableName,
array  $ids 
)
protected

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

Parameters
int[]$ids
Returns
‪array

Definition at line 1178 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\findItem().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\collectItems().

◆ filterNumericIds()

◆ findItem()

DataMapItem null TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::findItem ( string  $tableName,
  $id 
)
protected

◆ finishTranslationItem()

◆ getFieldNamesForItemScope()

◆ getFieldNamesToBeHandled()

string [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getFieldNamesToBeHandled ( string  $tableName)
protected

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

Returns
‪string[]

Definition at line 1404 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\State\getFieldNames(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\getLocalizationModeExcludeFieldNames().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\applyLocalizationReferences().

◆ getLanguageService()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getLanguageService ( )
protected

◆ getLocalizationModeExcludeFieldNames()

string [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getLocalizationModeExcludeFieldNames ( string  $tableName)
protected

◆ getPrefixLanguageTitleFieldNames()

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getPrefixLanguageTitleFieldNames ( string  $tableName)
protected

Field names of TCA table with columns having l10n_mode=prefixLangTitle

Returns
‪array

Definition at line 1417 of file DataMapProcessor.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\prefixLanguageTitle().

◆ isApplicable()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::isApplicable ( string  $tableName)
protected

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

Definition at line 1484 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\getLocalizationModeExcludeFieldNames(), and TYPO3\CMS\Core\DataHandling\Localization\State\isApplicable().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\collectItems().

◆ isReferenceField()

bool TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::isReferenceField ( string  $tableName,
string  $fieldName 
)
protected

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

Returns
‪bool TRUE if field is of type inline with foreign_table set

Definition at line 1465 of file DataMapProcessor.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\isRelationField(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeFieldValues().

◆ isRelationField()

bool TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::isRelationField ( string  $tableName,
string  $fieldName 
)
protected

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

Returns
‪bool True if field is type=group or select with foreign_table

Definition at line 1442 of file DataMapProcessor.php.

References $GLOBALS, and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\isReferenceField().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeFieldValues().

◆ isSetInDataMap()

bool TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::isSetInDataMap ( string  $tableName,
  $id,
string  $fieldName 
)
protected

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.

Parameters
string | int$id
Returns
‪bool

Definition at line 763 of file DataMapProcessor.php.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolveSuggestedInlineRelations(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeDirectRelations(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeFieldValues().

◆ mapRelationItemId()

int [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::mapRelationItemId ( array  $relationItems)
protected

◆ modifyDataMap()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::modifyDataMap ( string  $tableName,
  $id,
array  $values 
)
protected

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.

Parameters
string | int$id
Exceptions

Definition at line 782 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\modifiedDataMap.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeDirectRelations(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeFieldValues(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeReferences().

◆ populateTranslationItem()

◆ prefixLanguageTitle()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::prefixLanguageTitle ( string  $tableName,
  $fromId,
int  $language,
array  $data 
)
protected

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

Parameters
string | int$fromId

Definition at line 1293 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\getLanguageService(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\getPrefixLanguageTitleFieldNames().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeReferences().

◆ process()

◆ purgeDataMap()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::purgeDataMap ( array  $dataMap)
protected

Purges superfluous empty data-map sections.

Definition at line 162 of file DataMapProcessor.php.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\process().

◆ resolveAncestorId()

int null TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::resolveAncestorId ( array  $fieldNames,
array  $element 
)
protected
Parameters
array<string,string>‪$fieldNames
array<string,mixed>‪$element
Returns
‪int|null either a (non-empty) ancestor uid, or null if unresolved

Definition at line 1208 of file DataMapProcessor.php.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\buildElementAncestorIdMap(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchDependentIdMap().

◆ resolvePersistedInlineRelations()

int [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::resolvePersistedInlineRelations ( DataMapItem  $item,
string  $fieldName,
array  $forRecord 
)
private

◆ resolveSuggestedInlineRelations()

int [] string [] TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::resolveSuggestedInlineRelations ( DataMapItem  $item,
string  $fieldName,
array  $fromRecord 
)
protected

◆ sanitize()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::sanitize ( array  $items)
protected

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

Parameters
DataMapItem[]$items

Definition at line 254 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterItemsByType(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\sanitizeTranslationItem().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\process().

◆ sanitizeTranslationItem()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::sanitizeTranslationItem ( DataMapItem  $item)
protected

◆ synchronizeDirectRelations()

◆ synchronizeFieldValues()

◆ synchronizeReferences()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::synchronizeReferences ( DataMapItem  $item,
string  $fieldName,
array  $fromRecord,
array  $forRecord 
)
protected

Handle synchronization of references (inline or file). 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.

Exceptions

Definition at line 507 of file DataMapProcessor.php.

References $GLOBALS, TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\applyLocalizationReferences(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\backendUser, TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\fetchDependentIdMap(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterNumericIds(), TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\getId(), TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\getLanguage(), TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\getTableName(), TYPO3\CMS\Core\Utility\StringUtility\getUniqueId(), TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\isNew(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\modifyDataMap(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\prefixLanguageTitle(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\referenceIndexUpdater, TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolvePersistedInlineRelations(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolveSuggestedInlineRelations(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeFieldValues().

◆ synchronizeTranslationItem()

Member Data Documentation

◆ $allDataMap

array TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$allDataMap = array( )
protected

◆ backendUser

◆ modifiedDataMap

array<string, $modifiedDataMap = array( ); protected array<string, $sanitizationMap = array( ); protected BackendUserAuthentication $backendUser; protected ReferenceIndexUpdater $referenceIndexUpdater; protected DataMapItem[] $allItems = array( ); protected DataMapItem[] $nextItems = array( ); public static DataMapProcessor function instance( array $dataMap, BackendUserAuthentication $backendUser, ReferenceIndexUpdater $referenceIndexUpdater = null ) { return GeneralUtility::makeInstance( static::class, $dataMap, $backendUser, $referenceIndexUpdater ); } public function __construct( array $dataMap, BackendUserAuthentication $backendUser, ReferenceIndexUpdater $referenceIndexUpdater = null ) { $this->allDataMap = $dataMap; $this-> TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::modifiedDataMap = $dataMap
protected

◆ referenceIndexUpdater

if ( $referenceIndexUpdater===null) $this TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::referenceIndexUpdater = $referenceIndexUpdater