function FieldTranslationSynchronizer::itemHash
Same name in other branches
- 9 core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::itemHash()
- 8.9.x core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::itemHash()
- 10 core/modules/content_translation/src/FieldTranslationSynchronizer.php \Drupal\content_translation\FieldTranslationSynchronizer::itemHash()
Computes a hash code for the specified item.
Parameters
array $items: An array of field items.
int $delta: The delta identifying the item to be processed.
array $properties: An array of column names to be synchronized.
Return value
string A hash code that can be used to identify the item.
1 call to FieldTranslationSynchronizer::itemHash()
- FieldTranslationSynchronizer::synchronizeItems in core/
modules/ content_translation/ src/ FieldTranslationSynchronizer.php
File
-
core/
modules/ content_translation/ src/ FieldTranslationSynchronizer.php, line 334
Class
- FieldTranslationSynchronizer
- Provides field translation synchronization capabilities.
Namespace
Drupal\content_translationCode
protected function itemHash(array $items, $delta, array $properties) {
$values = [];
if (isset($items[$delta])) {
foreach ($properties as $property) {
if (!empty($items[$delta][$property])) {
$value = $items[$delta][$property];
// String and integer values are by far the most common item values,
// thus we special-case them to improve performance.
$values[] = is_string($value) || is_int($value) ? $value : hash('sha256', serialize($value));
}
else {
// Explicitly track also empty values.
$values[] = '';
}
}
}
return implode('.', $values);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.