From: Eileen McNaughton Date: Wed, 10 Aug 2022 04:26:58 +0000 (+1200) Subject: dev/core#3664 Remove dataColumnGuessing X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f4639afa782e5cfe67823325ab284a30cba7af9a;p=civicrm-core.git dev/core#3664 Remove dataColumnGuessing --- diff --git a/CRM/Activity/Import/Form/MapField.php b/CRM/Activity/Import/Form/MapField.php index 7034eb898b..155d6357e4 100644 --- a/CRM/Activity/Import/Form/MapField.php +++ b/CRM/Activity/Import/Form/MapField.php @@ -64,9 +64,9 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField { /** * Build the form object. * - * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ - public function buildQuickForm() { + public function buildQuickForm(): void { $savedMappingID = (int) $this->getSubmittedValue('savedMapping'); $this->buildSavedMappingFields($savedMappingID); $this->addFormRule(['CRM_Activity_Import_Form_MapField', 'formRule']); @@ -75,7 +75,6 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField { $defaults = []; $headerPatterns = $this->getHeaderPatterns(); - $dataPatterns = $this->getDataPatterns(); $fieldMappings = $this->getFieldMappings(); $columnHeaders = $this->getColumnHeaders(); $hasHeaders = $this->getSubmittedValue('skipColumnHeader'); @@ -112,9 +111,6 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField { if ($hasHeaders) { $defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)]; } - else { - $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)]; - } } // End of load mapping. } @@ -127,10 +123,6 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField { 0, ]; } - else { - // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i), 0]; - } } $sel->setOptions([$sel1]); diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 4c24a7edff..833eb631cc 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -309,12 +309,6 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { ]; } } - else { - // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = [ - $this->defaultFromData($this->getDataPatterns(), $i), - ]; - } $last_key = array_key_last($defaults["mapper[$i]"]) ?? 0; } // Call swapOptions on the deepest select element to hide the empty select lists above it. diff --git a/CRM/Contact/Import/MetadataTrait.php b/CRM/Contact/Import/MetadataTrait.php index 368df0e11a..19db539ed8 100644 --- a/CRM/Contact/Import/MetadataTrait.php +++ b/CRM/Contact/Import/MetadataTrait.php @@ -85,15 +85,6 @@ trait CRM_Contact_Import_MetadataTrait { return CRM_Utils_Array::collect('headerPattern', $this->getContactImportMetadata()); } - /** - * Get an array of header patterns for importable keys. - * - * @return array - */ - public function getDataPatterns(): array { - return CRM_Utils_Array::collect('dataPattern', $this->getContactImportMetadata()); - } - /** * Get an array of header patterns for importable keys. * diff --git a/CRM/Contribute/Import/Form/MapField.php b/CRM/Contribute/Import/Form/MapField.php index 419d91dd30..d4b5a81622 100644 --- a/CRM/Contribute/Import/Form/MapField.php +++ b/CRM/Contribute/Import/Form/MapField.php @@ -140,7 +140,6 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { $mapperKeys = array_keys($this->_mapperFields); $hasHeaders = $this->getSubmittedValue('skipColumnHeader'); $headerPatterns = $this->getHeaderPatterns(); - $dataPatterns = $this->getDataPatterns(); $mapperKeysValues = $this->getSubmittedValue('mapper'); $columnHeaders = $this->getColumnHeaders(); $fieldMappings = $this->getFieldMappings(); @@ -214,9 +213,6 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { if ($hasHeaders) { $defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)]; } - else { - $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)]; - } } //end of load mapping } @@ -237,13 +233,6 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField { ]; } } - else { - // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = [ - $this->defaultFromData($dataPatterns, $i), - 0, - ]; - } if (!empty($mapperKeysValues) && ($mapperKeysValues[$i][0] ?? NULL) === 'soft_credit') { $softCreditField = $mapperKeysValues[$i][1]; $softCreditTypeID = $mapperKeysValues[$i][2]; diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 94feb7729c..c374e1d956 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -348,7 +348,6 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { $mapperKeys = array_keys($this->_mapperFields); $hasHeaders = $this->getSubmittedValue('skipColumnHeader'); $headerPatterns = $this->getHeaderPatterns(); - $dataPatterns = $this->getDataPatterns(); $fieldMappings = $this->getFieldMappings(); /* Initialize all field usages to false */ @@ -387,9 +386,6 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { if ($hasHeaders) { $defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)]; } - else { - $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)]; - } } //end of load mapping } @@ -405,14 +401,6 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { 0, ]; } - else { - // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = [ - $this->defaultFromData($dataPatterns, $i), - // $defaultLocationType->id - 0, - ]; - } } $sel->setOptions([$sel1]); } diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index c9636b25bc..13801eb20b 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -649,15 +649,6 @@ class CRM_Import_Forms extends CRM_Core_Form { return []; } - /** - * Get the data patterns to pattern match the incoming data. - * - * @return array - */ - public function getDataPatterns(): array { - return $this->getParser()->getDataPatterns(); - } - /** * Get the data patterns to pattern match the incoming data. * diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 086cb4e628..8e7199bcb3 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -583,19 +583,6 @@ abstract class CRM_Import_Parser implements UserJobInterface { return $values; } - /** - * @deprecated - * - * @return array - */ - public function getDataPatterns():array { - $values = []; - foreach ($this->_fields as $name => $field) { - $values[$name] = $field->_dataPattern; - } - return $values; - } - /** * Remove single-quote enclosures from a value array (row). * diff --git a/CRM/Member/Import/Form/MapField.php b/CRM/Member/Import/Form/MapField.php index bee1f3a925..ab938e4abb 100644 --- a/CRM/Member/Import/Form/MapField.php +++ b/CRM/Member/Import/Form/MapField.php @@ -23,9 +23,9 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField { /** * Build the form object. * - * @return void + * @throws \CRM_Core_Exception */ - public function buildQuickForm() { + public function buildQuickForm(): void { $this->buildSavedMappingFields($this->getSubmittedValue('savedMapping')); $this->addFormRule(array('CRM_Member_Import_Form_MapField', 'formRule'), $this); @@ -35,7 +35,6 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField { $columnHeaders = $this->getColumnHeaders(); $hasHeaders = $this->getSubmittedValue('skipColumnHeader'); $headerPatterns = $this->getHeaderPatterns(); - $dataPatterns = $this->getDataPatterns(); // For most fields using the html label is a good thing // but for contact ID we really want to specify ID. $this->_mapperFields['membership_contact_id'] = ts('Contact ID'); @@ -84,9 +83,6 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField { if ($hasHeaders) { $defaults["mapper[$i]"] = array($this->defaultFromHeader($columnHeader, $headerPatterns)); } - else { - $defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i)); - } } //end of load mapping } @@ -102,14 +98,6 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField { 0, ); } - else { - // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = array( - $this->defaultFromData($dataPatterns, $i), - // $defaultLocationType->id - 0, - ); - } } $sel->setOptions([$sel1]); }