CRM-20786 consolidate calls to deprecated function
authoreileen <emcnaughton@wikimedia.org>
Wed, 28 Jun 2017 21:26:37 +0000 (09:26 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 29 Jun 2017 04:07:00 +0000 (16:07 +1200)
CRM/Contribute/Import/Parser/Contribution.php
CRM/Event/Import/Parser/Participant.php
CRM/Import/Parser.php
CRM/Member/Import/Parser/Membership.php

index c7529b517d37b69e01a53a953af9f42874005a10..05736a628028a5befa8c0b2077febb2855313740 100644 (file)
@@ -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]);
index 5d5b2431ee9f480badee5041a8423dc17c928eaf..16dfe0b7379d258343c11985eed3d8c04aa00c6a 100644 (file)
@@ -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]);
index 7791b129a9ad7cb5b97a0931355e2fe48d5eb2a8..c4169c2c5d37dcaefbe24996c5c3dda1ed0535b8 100644 (file)
@@ -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;
+  }
+
 }
index 7d112472656642f29d630125d5eb4842d911361a..ebe659dd2d76271b14193eed38c1aa8738dadd46 100644 (file)
@@ -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]);