public function FeedImportMergeOverwrite::merge in Feed Import 8
Merge the new and current field values. The merge should be set in $current ref. variable
Parameters
array $current: Current field values
array $new: New field values
array $field: Field info cardinality - field cardinality compare - compare function for field value
Return value
bool True if $current was changed
Overrides FeedImportMergeField::merge
File
- feed_import_base/
src/ FeedImportMergeOverwrite.php, line 20
Class
- FeedImportMergeOverwrite
- Class which overwrites values. A simple value by value comparison is made. This also overwrites values if missing from source.
Namespace
Drupal\feed_import_baseCode
public function merge(array &$current, array &$new, array &$field) {
$cnt = count($new);
if ($cnt != count($current)) {
// Different number of values.
$current = $new;
return TRUE;
}
// Same number of values. Might be the same.
$changed = FALSE;
for ($i = 0; $i < $cnt; $i++) {
if (!$field['compare']($new[$i], $current[$i])) {
$current[$i] = $new[$i];
$changed = TRUE;
}
}
return $changed;
}