You are here

protected function Attribute::rowUnique in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/csv_example/src/Plugin/migrate/source/Attribute.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\Attribute::rowUnique()
  2. 3.1.x modules/csv_example/src/Plugin/migrate/source/Attribute.php \Drupal\commerce_migrate_csv_example\Plugin\migrate\source\Attribute::rowUnique()

Tests if the row is unique.

Parameters

array $row: An array of attribute_name and attribute_value for the current row.

Return value

bool Return TRUE if the row is unique, FALSE if it is not unique.

1 call to Attribute::rowUnique()
Attribute::getYield in modules/csv_example/src/Plugin/migrate/source/Attribute.php
Prepares one row per attribute pair in the source row.

File

modules/csv_example/src/Plugin/migrate/source/Attribute.php, line 65

Class

Attribute
Yields each attribute name and value pair.

Namespace

Drupal\commerce_migrate_csv_example\Plugin\migrate\source

Code

protected function rowUnique(array $row) {
  static $unique_rows = [];
  foreach ($unique_rows as $unique) {
    if ($unique['attribute_name'] === $row['attribute_name'] && $unique['attribute_value'] === $row['attribute_value']) {
      return FALSE;
    }
  }
  $unique_rows[] = $row;
  return TRUE;
}