TYPO3 CMS  TYPO3_8-7
TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor Class Reference

Public Member Functions

 __construct (array $dataMap, BackendUserAuthentication $backendUser)
 
 process ()
 

Static Public Member Functions

static instance (array $dataMap, BackendUserAuthentication $backendUser)
 

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)
 
 synchronizeInlineRelations (DataMapItem $item, string $fieldName, array $fromRecord, array $forRecord)
 
 resolveSuggestedInlineRelations (DataMapItem $item, string $fieldName, array $fromRecord)
 
 isSetInDataMap (string $tableName, $id, string $fieldName)
 
 modifyDataMap (string $tableName, $id, array $values)
 
 addNextItem (DataMapItem $item)
 
 fetchTranslationValues (string $tableName, array $fieldNames, array $ids)
 
 fetchDependencies (string $tableName, array $ids)
 
 fetchDependentIdMap (string $tableName, array $ids, int $desiredLanguage)
 
 fetchDependentElements (string $tableName, array $ids, array $fieldNames)
 
 filterItemsByType (string $type, array $items)
 
 filterNumericIds (array $ids, bool $numeric=true)
 
 filterNewItemIds (string $tableName, array $ids)
 
 mapRelationItemId (array $relationItems)
 
 resolveAncestorId (array $fieldNames, array $element)
 
 buildElementAncestorIdMap (array $fieldNames, array $elements)
 
 findItem (string $tableName, $id)
 
 duplicateFromDataMap (string $tableName, $fromId, int $language, array $fieldNames, bool $localize)
 
 getFieldNamesForItemScope (DataMapItem $item, string $scope, bool $modified)
 
 getLocalizationModeExcludeFieldNames (string $tableName)
 
 getFieldNamesToBeHandled (string $tableName)
 
 getPrefixLanguageTitleFieldNames (string $tableName)
 
 isRelationField (string $tableName, string $fieldName)
 
 isInlineRelationField (string $tableName, string $fieldName)
 
 isApplicable (string $tableName)
 
 createRelationHandler ()
 
 getLanguageService ()
 

Protected Attributes

 $allDataMap = []
 
 $modifiedDataMap = []
 
 $sanitizationMap = []
 
 $backendUser
 
 $allItems = []
 
 $nextItems = []
 

Private Member Functions

 resolvePersistedInlineRelations (DataMapItem $item, string $fieldName, array $forRecord)
 

Detailed Description

This processor analyses 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

Definition at line 47 of file DataMapProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::__construct ( array  $dataMap,
BackendUserAuthentication  $backendUser 
)
Parameters
array$dataMapThe submitted data-map to be worked on
BackendUserAuthentication$backendUserForwared backend-user scope

Definition at line 99 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\$backendUser.

Member Function Documentation

◆ addNextItem()

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

◆ buildElementAncestorIdMap()

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 1206 of file DataMapProcessor.php.

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

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

◆ collectItems()

◆ createRelationHandler()

◆ duplicateFromDataMap()

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

◆ enrich()

◆ fetchDependencies()

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 872 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\Backend\Utility\BackendUtility\isTableLocalizable(), 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()

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

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.

Parameters
string$tableName
array$ids
array$fieldNames
Returns
array
Exceptions

Definition at line 1036 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterNumericIds(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

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

◆ fetchDependentIdMap()

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 953 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(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableLocalizable(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\resolveAncestorId().

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

◆ fetchTranslationValues()

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

Fetches translation related field values for the items submitted in the data-map. That's why further adjustment for the tables pages vs. pages_language_overlay is not required.

Parameters
string$tableName
array$fieldNames
array$ids
Returns
array

Definition at line 829 of file DataMapProcessor.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

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

◆ filterItemsByType()

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

Return array of data map items that are of given type

Parameters
string$type
DataMapItem[]$items
Returns
DataMapItem[]

Definition at line 1115 of file DataMapProcessor.php.

References TYPO3\CMS\Core\DataHandling\Localization\DataMapItem\getType().

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\enrich(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\sanitize().

◆ filterNewItemIds()

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

Definition at line 1149 of file DataMapProcessor.php.

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

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

◆ filterNumericIds()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::filterNumericIds ( array  $ids,
bool  $numeric = true 
)
protected

◆ findItem()

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

See if an items is in item list and return it

Parameters
string$tableName
string | int$id
Returns
DataMapItem|null

Definition at line 1225 of file DataMapProcessor.php.

Referenced by TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\collectItems(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\filterNewItemIds(), and TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\populateTranslationItem().

◆ finishTranslationItem()

◆ getFieldNamesForItemScope()

◆ getFieldNamesToBeHandled()

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.

Parameters
string$tableName
Returns
string[]

Definition at line 1357 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\duplicateFromDataMap().

◆ getLanguageService()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::getLanguageService ( )
protected
Returns
LanguageService|null

Definition at line 1475 of file DataMapProcessor.php.

References $GLOBALS.

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

◆ getLocalizationModeExcludeFieldNames()

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

◆ getPrefixLanguageTitleFieldNames()

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

Field names of TCA table with columns having l10n_mode=prefixLangTitle

Parameters
string$tableName
Returns
array

Definition at line 1371 of file DataMapProcessor.php.

References $GLOBALS.

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

◆ instance()

static TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::instance ( array  $dataMap,
BackendUserAuthentication  $backendUser 
)
static

Class generator

Parameters
array$dataMapThe submitted data-map to be worked on
BackendUserAuthentication$backendUserForwared backend-user scope
Returns
DataMapProcessor

Definition at line 86 of file DataMapProcessor.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Core\DataHandling\DataHandler\getCheckModifyAccessListHookObjects().

◆ 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.

Parameters
string$tableName
Returns
bool

Definition at line 1453 of file DataMapProcessor.php.

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

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

◆ isInlineRelationField()

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

True if we're dealing with an inline field

Parameters
string$tableName
string$fieldName
Returns
bool TRUE if field is of type inline with foreign_table set

Definition at line 1431 of file DataMapProcessor.php.

References $GLOBALS.

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

◆ isRelationField()

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

Parameters
string$tableName
string$fieldName
Returns
bool True if field is type=group with internalType === db or select with foreign_table

Definition at line 1402 of file DataMapProcessor.php.

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

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

◆ isSetInDataMap()

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$tableName
string | int$id
string$fieldName
Returns
bool

Definition at line 755 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()

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$tableName
string | int$id
array$values
Exceptions

Definition at line 776 of file DataMapProcessor.php.

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

◆ populateTranslationItem()

◆ process()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::process ( )

◆ purgeDataMap()

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

Purges superfluous empty data-map sections.

Parameters
array$dataMap
Returns
array

Definition at line 143 of file DataMapProcessor.php.

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

◆ resolveAncestorId()

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::resolveAncestorId ( array  $fieldNames,
array  $element 
)
protected

◆ resolvePersistedInlineRelations()

◆ resolveSuggestedInlineRelations()

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 247 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()

◆ synchronizeInlineRelations()

◆ synchronizeTranslationItem()

Member Data Documentation

◆ $allDataMap

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$allDataMap = []
protected

◆ $allItems

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$allItems = []
protected

Definition at line 72 of file DataMapProcessor.php.

◆ $backendUser

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$backendUser
protected

◆ $modifiedDataMap

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$modifiedDataMap = []
protected

Definition at line 57 of file DataMapProcessor.php.

◆ $nextItems

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$nextItems = []
protected

Definition at line 77 of file DataMapProcessor.php.

◆ $sanitizationMap

TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor::$sanitizationMap = []
protected

Definition at line 62 of file DataMapProcessor.php.