class FeedImportMergeOverwrite in Feed Import 8
Class which overwrites values. A simple value by value comparison is made. This also overwrites values if missing from source.
Hierarchy
- class \Drupal\feed_import_base\FeedImportMergeField
- class \Drupal\feed_import_base\FeedImportMergeOverwrite
Expanded class hierarchy of FeedImportMergeOverwrite
File
- feed_import_base/
src/ FeedImportMergeOverwrite.php, line 8
Namespace
Drupal\feed_import_baseView source
class FeedImportMergeOverwrite extends FeedImportMergeField {
/**
* {@inheritdoc}
*/
public function overwriteEmpty() {
return TRUE;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedImportMergeOverwrite:: |
public | function |
Merge the new and current field values.
The merge should be set in $current ref. variable Overrides FeedImportMergeField:: |
|
FeedImportMergeOverwrite:: |
public | function |
Remove field if is missing from source. Overrides FeedImportMergeField:: |