From 97267376d04e22b9accf25be43022c844210bdda Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 9 Jun 2022 18:29:50 +1200 Subject: [PATCH] Remove unused functions These used to be called from run - which is gone itself now --- .toxic.json | 1 - CRM/Contact/Import/Parser/Contact.php | 89 --------------------------- 2 files changed, 90 deletions(-) diff --git a/.toxic.json b/.toxic.json index 399c2407ac..a2620d1316 100644 --- a/.toxic.json +++ b/.toxic.json @@ -16,7 +16,6 @@ "CRM_Contact_Import_Form_MapField::buildQuickForm()": "toxicAlert", "CRM_Contact_Import_Parser_Contact::formatCommonData()": "toxicAlert", "CRM_Contact_Import_Parser_Contact::formatContactParameters()": "toxicAlert", - "CRM_Contact_Import_Parser_Contact::run()": "toxicAlert", "CRM_Contact_Import_Parser_Contact::import()": "toxicAlert", "CRM_Contribute_BAO_Contribution::recordFinancialAccounts()": "toxicAlert", "CRM_Contribute_BAO_Contribution::transitionComponents()": "toxicAlert", diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 4e3a454069..137d61d88a 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -104,49 +104,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { return (bool) (CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options')['street_address_parsing'] ?? FALSE); } - /** - * Handle the values in preview mode. - * - * Function will be deprecated in favour of validateValues. - * - * @param array $values - * The array of values belonging to this line. - * - * @return bool - * the result of this processing - * CRM_Import_Parser::ERROR or CRM_Import_Parser::VALID - */ - public function preview(&$values) { - return $this->summary($values); - } - - /** - * Handle the values in summary mode. - * - * Function will be deprecated in favour of validateValues. - * - * @param array $values - * The array of values belonging to this line. - * - * @return int - * the result of this processing - * CRM_Import_Parser::ERROR or CRM_Import_Parser::VALID - */ - public function summary(&$values): int { - $rowNumber = (int) ($values[array_key_last($values)]); - try { - $this->validateValues($values); - } - catch (CRM_Core_Exception $e) { - $this->setImportStatus($rowNumber, 'ERROR', $e->getMessage()); - array_unshift($values, $e->getMessage()); - return CRM_Import_Parser::ERROR; - } - $this->setImportStatus($rowNumber, 'NEW', ''); - - return CRM_Import_Parser::VALID; - } - /** * Handle the values in import mode. * @@ -1149,52 +1106,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { public function set($store, $mode = self::MODE_SUMMARY) { } - /** - * Export data to a CSV file. - * - * @param string $fileName - * @param array $header - * @param array $data - */ - public static function exportCSV($fileName, $header, $data) { - - if (file_exists($fileName) && !is_writable($fileName)) { - CRM_Core_Error::movedSiteError($fileName); - } - //hack to remove '_status', '_statusMsg' and '_id' from error file - $errorValues = []; - $dbRecordStatus = ['IMPORTED', 'ERROR', 'DUPLICATE', 'INVALID', 'NEW']; - foreach ($data as $rowCount => $rowValues) { - $count = 0; - foreach ($rowValues as $key => $val) { - if (in_array($val, $dbRecordStatus) && $count == (count($rowValues) - 3)) { - break; - } - $errorValues[$rowCount][$key] = $val; - $count++; - } - } - $data = $errorValues; - - $output = []; - $fd = fopen($fileName, 'w'); - - foreach ($header as $key => $value) { - $header[$key] = "\"$value\""; - } - $config = CRM_Core_Config::singleton(); - $output[] = implode($config->fieldSeparator, $header); - - foreach ($data as $datum) { - foreach ($datum as $key => $value) { - $datum[$key] = "\"$value\""; - } - $output[] = implode($config->fieldSeparator, $datum); - } - fwrite($fd, implode("\n", $output)); - fclose($fd); - } - /** * Format contact parameters. * -- 2.25.1