protected function FieldTranslationSynchronizer::itemHash

Computes a hash code for the specified item.

@returns string A hash code that can be used to identify the item.

Parameters

array $items: An array of field items.

integer $delta: The delta identifying the item to be processed.

array $columns: An array of column names to be synchronized.

1 call to FieldTranslationSynchronizer::itemHash()
FieldTranslationSynchronizer::synchronizeItems in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizer.php
Synchronize the items of a single field.

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizer.php, line 202
Contains \Drupal\translation_entity\FieldTranslationSynchronizer.

Class

FieldTranslationSynchronizer
Provides field translation synchronization capabilities.

Namespace

Drupal\translation_entity

Code

protected function itemHash(array $items, $delta, array $columns) {
  $values = array();
  if (isset($items[$delta])) {
    foreach ($columns as $column) {
      if (!empty($items[$delta][$column])) {
        $value = $items[$delta][$column];

        // 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);
}