You are here

class FeedImportMergeOverwrite in Feed Import 7.3

Class which overwrites values. A simple value by value comparison is made. This also overwrites values if missing from source.

Hierarchy

Expanded class hierarchy of FeedImportMergeOverwrite

1 string reference to 'FeedImportMergeOverwrite'
feed_import_base_feed_import_field_merge_classes in feed_import_base/feed_import_base.module
Implements hook_feed_import_field_merge_classes().

File

feed_import_base/inc/feed_import_merge.inc, line 92
This file contains Feed Import field merge methods.

View 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

Namesort descending Modifiers Type Description Overrides
FeedImportMergeOverwrite::merge public function Merge the new and current field values. The merge should be set in $current ref. variable Overrides FeedImportMergeField::merge
FeedImportMergeOverwrite::overwriteEmpty public function Remove field if is missing from source. Overrides FeedImportMergeField::overwriteEmpty