You are here

public function PreprocessorPluginManager::sourceFieldIsSameOfOriginal in Geocoder 8.2

Same name and namespace in other branches
  1. 8.3 modules/geocoder_field/src/PreprocessorPluginManager.php \Drupal\geocoder_field\PreprocessorPluginManager::sourceFieldIsSameOfOriginal()

Check if the source and the original fields are the same.

Parameters

\Drupal\Core\Field\FieldItemListInterface $source_field: The Source Field.

\Drupal\Core\Field\FieldItemListInterface $original_field: The Original Field.

Return value

bool The check result.

File

modules/geocoder_field/src/PreprocessorPluginManager.php, line 115

Class

PreprocessorPluginManager
Provides a plugin manager for geocoder data preprocessors.

Namespace

Drupal\geocoder_field

Code

public function sourceFieldIsSameOfOriginal(FieldItemListInterface $source_field, FieldItemListInterface $original_field) {
  $source_value = $source_field
    ->getValue();
  $original_value = $original_field
    ->getValue();
  if (isset($source_value[0]) && !isset($source_value[0]['value']) && isset($source_value[0]['target_id'])) {
    foreach ($source_value as $i => $value) {
      $source_value[$i] = isset($value['target_id']) ? $value['target_id'] : '';
    }
  }
  if (isset($original_value[0]) && !isset($original_value[0]['value']) && isset($original_value[0]['target_id'])) {
    foreach ($original_value as $i => $value) {
      $original_value[$i] = isset($value['target_id']) ? $value['target_id'] : '';
    }
  }
  return $source_value == $original_value;
}