CRM-20786 Move deprecated utils functions to the import classes
authoreileen <emcnaughton@wikimedia.org>
Wed, 28 Jun 2017 20:59:35 +0000 (08:59 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 28 Jun 2017 21:04:03 +0000 (09:04 +1200)
CRM/Contact/Import/Parser/Contact.php

index ad6f41a035b8b4126aa439abf8a6ed5d0d99352c..f07bb3ca6b88c8b4b0db29249a99e92de5499d82 100644 (file)
@@ -24,7 +24,7 @@
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
  */
-
+require_once 'CRM/Utils/DeprecatedUtils.php';
 /**
  *
  * @package CRM
@@ -1953,8 +1953,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           }
 
           if (!$break) {
-            require_once 'CRM/Utils/DeprecatedUtils.php';
-            _civicrm_api3_deprecated_add_formatted_param($value, $formatted);
+            list($value, $formatted) = $this->formatContactParameters();
           }
         }
         if (!$isAddressCustomField) {
@@ -1976,11 +1975,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
       if ($key == 'id' && isset($field)) {
         $formatted[$key] = $field;
       }
-      require_once 'CRM/Utils/DeprecatedUtils.php';
-      _civicrm_api3_deprecated_add_formatted_param($formatValues, $formatted);
+      $this->formatContactParameters($formatValues, $formatted);
 
       //Handling Custom Data
-      // note: Address custom fields will be handled separately inside _civicrm_api3_deprecated_add_formatted_param
+      // note: Address custom fields will be handled separately inside formatContactParameters
       if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) &&
         array_key_exists($customFieldID, $customFields) &&
         !array_key_exists($customFieldID, $addressCustomFields)
@@ -2251,4 +2249,21 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
 
   }
 
+  /**
+   * Format contact parameters.
+   *
+   * @todo this function needs re-writing & re-merging into the main function.
+   *
+   * Here be dragons.
+   *
+   * @param array $values
+   * @param array $params
+   *
+   * @return bool
+   */
+  protected function formatContactParameters(&$values, &$params) {
+    _civicrm_api3_deprecated_add_formatted_param($values, $params);
+    return TRUE;
+  }
+
 }