From 109d3fe734261a734ae618d277023863ccfab992 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 25 Aug 2022 08:57:50 -0400 Subject: [PATCH] REF - Extract CRM_Contact_BAO_Contact::findDuplicates --- CRM/Contact/BAO/Contact.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index eaf2c20661..d76836577a 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -3474,11 +3474,29 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id ) $dedupeParams['rule'] = $rule; $dedupeParams['rule_group_id'] = $ruleGroupID; $dedupeParams['excluded_contact_ids'] = $excludedContactIDs; - $dedupeResults['ids'] = []; - $dedupeResults['handled'] = FALSE; + return self::findDuplicates($dedupeParams, $contextParams ?: []); + } + + /** + * @param array $dedupeParams + * @param array $contextParams + * @return array + * @throws CRM_Core_Exception + */ + public static function findDuplicates(array $dedupeParams, array $contextParams = []): array { + $dedupeResults = [ + 'ids' => [], + 'handled' => FALSE, + ]; CRM_Utils_Hook::findDuplicates($dedupeParams, $dedupeResults, $contextParams); if (!$dedupeResults['handled']) { - $dedupeResults['ids'] = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, $rule, $excludedContactIDs, $ruleGroupID); + $dedupeParams += [ + 'contact_type' => NULL, + 'rule' => NULL, + 'rule_group_id' => NULL, + 'excluded_contact_ids' => [], + ]; + $dedupeResults['ids'] = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $dedupeParams['contact_type'], $dedupeParams['rule'], $dedupeParams['excluded_contact_ids'], $dedupeParams['rule_group_id']); } return $dedupeResults['ids'] ?? []; } -- 2.25.1