function FieldTranslationSynchronizer::createMergedItem

Same name in other branches
  1. 8.9.x core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::createMergedItem()
  2. 10 core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::createMergedItem()
  3. 11.x core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::createMergedItem()

Creates a merged item.

Parameters

array $source_item: An item containing the untranslatable properties to be synchronized.

array $target_item: An item containing the translatable properties to be kept.

string[] $properties: An array of properties to be synchronized.

Return value

array A merged item array.

1 call to FieldTranslationSynchronizer::createMergedItem()
FieldTranslationSynchronizer::synchronizeItems in core/modules/content_translation/src/FieldTranslationSynchronizer.php
Synchronize the items of a single field.

File

core/modules/content_translation/src/FieldTranslationSynchronizer.php, line 313

Class

FieldTranslationSynchronizer
Provides field translation synchronization capabilities.

Namespace

Drupal\content_translation

Code

protected function createMergedItem(array $source_item, array $target_item, array $properties) {
    $property_keys = array_flip($properties);
    $item_properties_to_sync = array_intersect_key($source_item, $property_keys);
    $item_properties_to_keep = array_diff_key($target_item, $property_keys);
    return $item_properties_to_sync + $item_properties_to_keep;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.