private function ReferenceMigrator::removeDuplicates in Term reference change 8
Removes duplicate references from the values array.
Parameters
array $values: The values array.
Return value
array The values array without duplicates.
1 call to ReferenceMigrator::removeDuplicates()
- ReferenceMigrator::updateReferencingEntity in src/
ReferenceMigrator.php - Changes the reference of an entity from the source term to the target term.
File
- src/
ReferenceMigrator.php, line 191
Class
- ReferenceMigrator
- Migrates references from one taxonomy term to the other.
Namespace
Drupal\term_reference_changeCode
private function removeDuplicates(array $values) {
$unique = [];
foreach ($values as $id => $value) {
if (isset($unique[$value['target_id']])) {
unset($values[$id]);
continue;
}
$unique[$value['target_id']] = $value['target_id'];
}
return array_values($values);
}