From 563167470ff81ab5e6335ae11f6aaef5c4973379 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 29 Jun 2017 09:26:37 +1200 Subject: [PATCH] CRM-20786 consolidate calls to deprecated function --- CRM/Contribute/Import/Parser/Contribution.php | 5 +---- CRM/Event/Import/Parser/Participant.php | 9 +-------- CRM/Import/Parser.php | 16 ++++++++++++++++ CRM/Member/Import/Parser/Membership.php | 7 +------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index c7529b517d..05736a6280 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -453,10 +453,7 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $paramValues['contact_type'] = $this->_contactType; } - $paramValues['version'] = 3; - //retrieve contact id using contact dedupe rule - require_once 'CRM/Utils/DeprecatedUtils.php'; - $error = _civicrm_api3_deprecated_check_contact_dedupe($paramValues); + $error = $this->checkContactDuplicate($paramValues); if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) { $matchedIDs = explode(',', $error['error_message']['params'][0]); diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index 5d5b2431ee..16dfe0b737 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -42,9 +42,6 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { protected $_mapperKeys; private $_contactIdIndex; - - //private $_totalAmountIndex; - private $_eventIndex; private $_participantStatusIndex; private $_participantRoleIndex; @@ -399,11 +396,7 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { } if ($this->_contactIdIndex < 0) { - - //retrieve contact id using contact dedupe rule - $formatValues['contact_type'] = $this->_contactType; - $formatValues['version'] = 3; - $error = _civicrm_api3_deprecated_check_contact_dedupe($formatValues); + $error = $this->checkContactDuplicate($formatValues); if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) { $matchedIDs = explode(',', $error['error_message']['params'][0]); diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 7791b129a9..c4169c2c5d 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -444,4 +444,20 @@ abstract class CRM_Import_Parser { return $fileName; } + /** + * Check if contact is a duplicate . + * + * @param array $formatValues + * + * @return array + */ + protected function checkContactDuplicate(&$formatValues) { + //retrieve contact id using contact dedupe rule + $formatValues['contact_type'] = $this->_contactType; + $formatValues['version'] = 3; + require_once 'CRM/Utils/DeprecatedUtils.php'; + $error = _civicrm_api3_deprecated_check_contact_dedupe($formatValues); + return $error; + } + } diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index 7d11247265..ebe659dd2d 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -415,12 +415,7 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { $joinDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $formatted), '%Y-%m-%d'); if ($this->_contactIdIndex < 0) { - - //retrieve contact id using contact dedupe rule - $formatValues['contact_type'] = $this->_contactType; - $formatValues['version'] = 3; - require_once 'CRM/Utils/DeprecatedUtils.php'; - $error = _civicrm_api3_deprecated_check_contact_dedupe($formatValues); + $error = $this->checkContactDuplicate($formatValues); if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) { $matchedIDs = explode(',', $error['error_message']['params'][0]); -- 2.25.1