Skip to content
Snippets Groups Projects
Unverified Commit dcfedf51 authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #31774 from colemanw/deprecatedParserFns

CRM_Import_Parser - Delete unused deprecated functions
parents 16c87974 521921c1
Branches
Tags
No related merge requests found
......@@ -448,59 +448,6 @@ abstract class CRM_Import_Parser implements UserJobInterface {
return $values;
}
/**
* Do this work on the form layer.
*
* @deprecated in 5.54 will be removed around 5.80
*
* @return array
*/
public function getHeaderPatterns(): array {
CRM_Core_Error::deprecatedFunctionWarning('CRM_Import_Forms::getHeaderPatterns');
$values = [];
foreach ($this->importableFieldsMetadata as $name => $field) {
if (isset($field['headerPattern'])) {
$values[$name] = $field['headerPattern'] ?: '//';
}
}
return $values;
}
/**
* Remove single-quote enclosures from a value array (row).
*
* @param array $values
* @param string $enclosure
*
* @deprecated
*
* @return void
*/
public static function encloseScrub(&$values, $enclosure = "'") {
CRM_Core_Error::deprecatedFunctionWarning('no replacement');
if (empty($values)) {
return;
}
foreach ($values as $k => $v) {
$values[$k] = preg_replace("/^$enclosure(.*)$enclosure$/", '$1', $v);
}
}
/**
* Setter function.
*
* @deprecated
*
* @param int $max
*
* @return void
*/
public function setMaxLinesToProcess($max) {
CRM_Core_Error::deprecatedFunctionWarning('no replacement');
$this->_maxLinesToProcess = $max;
}
/**
* Validate that we have the required fields to create the contact or find it to update.
*
......@@ -677,44 +624,6 @@ abstract class CRM_Import_Parser implements UserJobInterface {
return $tagAdditions;
}
/**
* Determines the file extension based on error code.
*
* @deprecated
*
* @var int $type error code constant
* @return string
*/
public static function errorFileName($type) {
CRM_Core_Error::deprecatedFunctionWarning('no replacement');
$fileName = NULL;
if (empty($type)) {
return $fileName;
}
$config = CRM_Core_Config::singleton();
$fileName = $config->uploadDir . "sqlImport";
switch ($type) {
case self::ERROR:
$fileName .= '.errors';
break;
case self::DUPLICATE:
$fileName .= '.duplicates';
break;
case self::NO_MATCH:
$fileName .= '.mismatch';
break;
case self::UNPARSED_ADDRESS_WARNING:
$fileName .= '.unparsedAddress';
break;
}
return $fileName;
}
/**
* Validate that a passed in contact ID is for an existing, not-deleted contact.
*
......@@ -1241,45 +1150,6 @@ abstract class CRM_Import_Parser implements UserJobInterface {
}
}
/**
* Parse a field which could be represented by a label or name value rather than the DB value.
*
* We will try to match name first or (per https://lab.civicrm.org/dev/core/issues/1285 if we have an id.
*
* but if not available then see if we have a label that can be converted to a name.
*
* @deprecated
*
* @param string|int|null $submittedValue
* @param array $fieldSpec
* Metadata for the field
*
* @return mixed
*/
protected function parsePseudoConstantField($submittedValue, $fieldSpec) {
CRM_Core_Error::deprecatedFunctionWarning('no replacement');
// dev/core#1289 Somehow we have wound up here but the BAO has not been specified in the fieldspec so we need to check this but future us problem, for now lets just return the submittedValue
if (!isset($fieldSpec['bao'])) {
return $submittedValue;
}
/** @var \CRM_Core_DAO $bao */
$bao = $fieldSpec['bao'];
// For historical reasons use validate as context - ie disabled name matches ARE permitted.
$nameOptions = $bao::buildOptions($fieldSpec['name'], 'validate');
if (isset($nameOptions[$submittedValue])) {
return $submittedValue;
}
if (in_array($submittedValue, $nameOptions)) {
return array_search($submittedValue, $nameOptions, TRUE);
}
$labelOptions = array_flip($bao::buildOptions($fieldSpec['name'], 'match'));
if (isset($labelOptions[$submittedValue])) {
return array_search($labelOptions[$submittedValue], $nameOptions, TRUE);
}
return '';
}
/**
* This is code extracted from 4 places where this exact snippet was being duplicated.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment