protected function prepareResult(array &$map, DedupeDataSourceResult $result) { $entityTypeID = $this->getEntityTypeID(); foreach ($map as $matchHash => &$entry) { $primaryQty = isset($entry['PRIMARY']) ? count($entry['PRIMARY']) : 0; $secondaryQty = isset($entry['SECONDARY']) ? count($entry['SECONDARY']) : 0; if ($primaryQty > 1) { $matches = $this->getEntityMatchesByHash($entityTypeID, $entry['PRIMARY'][0], $matchHash); if (is_array($matches)) { $criterion = $this->createCriterionFromMatches($matches); $dup = new Duplicate($criterion, array()); foreach ($entry['PRIMARY'] as $entityID) { $dup->addEntity(new DuplicateEntity($entityTypeID, $entityID)); } $result->addItem($matchHash, $dup); } } if ($primaryQty > 0 && $secondaryQty > 0) { $matches = $this->loadEntitesMatches($entityTypeID, $entry['SECONDARY']); foreach ($matches as $entityID => $entityMatches) { $criterion = $this->createCriterionFromMatches($entityMatches); $entityMatchHash = $criterion->getMatchHash(); if ($entityMatchHash === '') { continue; } $dup = $result->getItem($entityMatchHash); if (!$dup) { $dup = new Duplicate($criterion, array(new DuplicateEntity($entityTypeID, $entityID))); $dup->setOption('enableOverwrite', false); $dup->setRootEntityID($entityID); } $result->addItem($entityMatchHash, $dup); foreach ($entry['PRIMARY'] as $primaryEntityID) { $matches = $this->getEntityMatchesByHash($entityTypeID, $primaryEntityID, $matchHash); if (is_array($matches)) { $entity = new DuplicateEntity($entityTypeID, $primaryEntityID); $entity->setCriterion($this->createCriterionFromMatches($matches)); $dup->addEntity($entity); } } } } } unset($entry); }
protected function prepareResult(array &$map, DedupeDataSourceResult $result) { $entityTypeID = $this->getEntityTypeID(); foreach ($map as $matchHash => &$entry) { $primaryQty = isset($entry['PRIMARY']) ? count($entry['PRIMARY']) : 0; if ($primaryQty > 1) { $matches = $this->getEntityMatchesByHash($entityTypeID, $entry['PRIMARY'][0], $matchHash); if (is_array($matches)) { $criterion = $this->createCriterionFromMatches($matches); $dup = new Duplicate($criterion, array()); foreach ($entry['PRIMARY'] as $entityID) { $dup->addEntity(new DuplicateEntity($entityTypeID, $entityID)); } $result->addItem($matchHash, $dup); } } } unset($entry); }