You are here

class FeedImportMergeDuplicates in Feed Import 8

Class which merges field values without checking for duplicates.

Hierarchy

Expanded class hierarchy of FeedImportMergeDuplicates

File

feed_import_base/src/FeedImportMergeDuplicates.php, line 7

Namespace

Drupal\feed_import_base
View source
class FeedImportMergeDuplicates extends FeedImportMergeField {

  /**
   * {@inheritdoc}
   */
  public function merge(array &$current, array &$new, array &$field) {
    if ($field['cardinality'] == -1) {
      $current = array_merge($current, $new);
      return TRUE;
    }
    elseif (($cnt = count($current)) < $field['cardinality']) {
      $cnt = $field['cardinality'] - $cnt;
      $current = array_merge($current, count($new) <= $cnt ? $new : array_slice($new, 0, $cnt));
      return TRUE;
    }
    return FALSE;
  }

}

Members

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