From d38d07beb2cce8464313ae5a2a9b3b2af7a3c77b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 25 Aug 2022 12:52:23 +1200 Subject: [PATCH] Finally full remove the awful addField from import --- CRM/Contact/Import/Field.php | 188 -------------------------- CRM/Contact/Import/Parser/Contact.php | 42 +----- 2 files changed, 2 insertions(+), 228 deletions(-) delete mode 100644 CRM/Contact/Import/Field.php diff --git a/CRM/Contact/Import/Field.php b/CRM/Contact/Import/Field.php deleted file mode 100644 index 20d75656f9..0000000000 --- a/CRM/Contact/Import/Field.php +++ /dev/null @@ -1,188 +0,0 @@ -_name = $name; - $this->_title = $title; - $this->_type = $type; - $this->_columnPattern = $columnPattern; - $this->_dataPattern = $dataPattern; - $this->_hasLocationType = $hasLocationType; - $this->_phoneType = $phoneType; - $this->_related = $related; - $this->_relatedContactType = $relatedContactType; - $this->_relatedContactDetails = $relatedContactDetails; - $this->_relatedContactLocType = $relatedContactLocType; - $this->_relatedContactPhoneType = $relatedContactPhoneType; - - $this->_value = NULL; - } - - public function resetValue() { - $this->_value = NULL; - } - - /** - * The value is in string format. - * - * Convert the value to the type of this field - * and set the field value with the appropriate type - * - * @param string $value - */ - public function setValue($value) { - $this->_value = $value; - } - - /** - * Validate something we didn't document. - * - * @return bool - */ - public function validate() { - // echo $this->_value."===========
"; - $message = ''; - - if ($this->_value === NULL) { - return TRUE; - } - - // Commented due to bug CRM-150, internationalization/wew. - // if ( $this->_name == 'phone' ) { - // return CRM_Utils_Rule::phone( $this->_value ); - // } - - if ($this->_name == 'email') { - return CRM_Utils_Rule::email($this->_value); - } - } - -} diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index fc4737e2b6..abf42ebb78 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -28,7 +28,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { use CRM_Contact_Import_MetadataTrait; - protected $_mapperKeys = []; protected $_allExternalIdentifiers = []; /** @@ -80,9 +79,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { // Force re-load of user job. unset($this->userJob); $this->setFieldMetadata(); - foreach ($this->getImportableFieldsMetadata() as $name => $field) { - $this->addField($name, $field['title'], CRM_Utils_Array::value('type', $field), CRM_Utils_Array::value('headerPattern', $field), CRM_Utils_Array::value('dataPattern', $field), CRM_Utils_Array::value('hasLocationType', $field)); - } } /** @@ -139,14 +135,8 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { * * @param array $values * The array of values belonging to this line. - * - * @return bool - * the result of this processing - * - * @throws \CRM_Core_Exception - * @throws \API_Exception */ - public function import($values) { + public function import(array $values): void { $rowNumber = (int) $values[array_key_last($values)]; // Put this here for now since we're gettting run by a job and need to @@ -183,8 +173,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $hookParams = [ 'contactID' => $contactID, 'importID' => $currentImportID, - 'importTempTable' => $this->_tableName, - 'fieldHeaders' => $this->_mapperKeys, ]; CRM_Utils_Hook::import('Contact', 'process', $this, $hookParams); } @@ -210,13 +198,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { } catch (CRM_Core_Exception $e) { $this->setImportStatus($rowNumber, $this->getStatus($e->getErrorCode()), $e->getMessage()); - return FALSE; - } - // We can probably stop catching this once https://github.com/civicrm/civicrm-core/pull/23471 - // is merged - testImportParserWithExternalIdForRelationship will confirm.... - catch (CiviCRM_API3_Exception $e) { - $this->setImportStatus($rowNumber, $this->getStatus($e->getErrorCode()), $e->getMessage()); - return FALSE; + return; } $extraFields = ['related_contact_created' => 0, 'related_contact_matched' => 0]; foreach ($relatedContacts as $outcome) { @@ -228,7 +210,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { } } $this->setImportStatus($rowNumber, $this->getStatus(CRM_Import_Parser::VALID), $this->getSuccessMessage(), $contactID, $extraFields, array_merge(array_keys($relatedContacts), [$contactID])); - return CRM_Import_Parser::VALID; } /** @@ -1106,25 +1087,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $this->setImportableFieldsMetadata($this->getContactImportMetadata()); } - /** - * @param string $name - * @param $title - * @param int $type - * @param string $headerPattern - * @param string $dataPattern - * @param bool $hasLocationType - */ - public function addField( - $name, $title, $type = CRM_Utils_Type::T_INT, - $headerPattern = '//', $dataPattern = '//', - $hasLocationType = FALSE - ) { - $this->_fields[$name] = new CRM_Contact_Import_Field($name, $title, $type, $headerPattern, $dataPattern, $hasLocationType); - if (empty($name)) { - $this->_fields['doNotImport'] = new CRM_Contact_Import_Field($name, $title, $type, $headerPattern, $dataPattern, $hasLocationType); - } - } - /** * Format contact parameters. * -- 2.25.1