CRM_Contribute_Import_Parser_Contribution
class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Parser
Class to parse contribution csv files.
Constants
MAX_WARNINGS |
Settings |
DEFAULT_TIMEOUT |
Settings |
VALID |
Return codes |
WARNING |
Return codes |
ERROR |
Return codes |
CONFLICT |
Return codes |
STOP |
Return codes |
DUPLICATE |
Return codes |
MULTIPLE_DUPE |
Return codes |
NO_MATCH |
Return codes |
UNPARSED_ADDRESS_WARNING |
Return codes |
MODE_MAPFIELD |
Parser modes |
MODE_PREVIEW |
Parser modes |
MODE_SUMMARY |
Parser modes |
MODE_IMPORT |
Parser modes |
DUPLICATE_SKIP |
Codes for duplicate record handling |
DUPLICATE_REPLACE |
Codes for duplicate record handling |
DUPLICATE_UPDATE |
Codes for duplicate record handling |
DUPLICATE_FILL |
Codes for duplicate record handling |
DUPLICATE_NOCHECK |
Codes for duplicate record handling |
CONTACT_INDIVIDUAL |
Contact types |
CONTACT_HOUSEHOLD |
Contact types |
CONTACT_ORGANIZATION |
Contact types |
SOFT_CREDIT |
Contribution-specific result codes |
SOFT_CREDIT_ERROR |
Contribution-specific result codes |
PLEDGE_PAYMENT |
Contribution-specific result codes |
PLEDGE_PAYMENT_ERROR |
Contribution-specific result codes |
Properties
protected int | $_totalCount | Total number of non empty lines | from CRM_Import_Parser |
protected int | $_validCount | Running total number of valid lines | from CRM_Import_Parser |
protected int | $_invalidRowCount | Running total number of invalid rows | from CRM_Import_Parser |
protected int | $_maxLinesToProcess | Maximum number of non-empty/comment lines to process | from CRM_Import_Parser |
protected array | $_errors | Array of error lines, bounded by MAX_ERROR | from CRM_Import_Parser |
protected int | $_conflictCount | Total number of conflict lines | from CRM_Import_Parser |
protected array | $_conflicts | Array of conflict lines | from CRM_Import_Parser |
protected int | $_duplicateCount | Total number of duplicate (from database) lines | from CRM_Import_Parser |
protected array | $_duplicates | Array of duplicate lines | from CRM_Import_Parser |
protected int | $_warningCount | Running total number of warnings | from CRM_Import_Parser |
protected int | $_maxWarningCount | Maximum number of warnings to store | from CRM_Import_Parser |
protected array | $_warnings | Array of warning lines, bounded by MAX_WARNING | from CRM_Import_Parser |
protected array | $_fields | Array of all the fields that could potentially be part of this import process | from CRM_Import_Parser |
protected array | $importableFieldsMetadata | Metadata for all available fields, keyed by unique name. | from CRM_Import_Parser |
protected array | $_activeFields | Array of the fields that are actually part of the import process the position in the array also dictates their position in the import file | from CRM_Import_Parser |
protected int | $_activeFieldCount | Cache the count of active fields | from CRM_Import_Parser |
protected array | $_rows | Cache of preview rows | from CRM_Import_Parser |
protected string | $_errorFileName | Filename of error data | from CRM_Import_Parser |
protected string | $_conflictFileName | Filename of conflict data | from CRM_Import_Parser |
protected string | $_duplicateFileName | Filename of duplicate data | from CRM_Import_Parser |
int | $_contactType | Contact type | from CRM_Import_Parser |
int | $_contactSubType | Contact sub-type | from CRM_Import_Parser |
protected string | $_fileName | from CRM_Contribute_Import_Parser | |
protected int | $_fileSize | Imported file size | from CRM_Contribute_Import_Parser |
protected string | $_seperator | Seperator being used | from CRM_Contribute_Import_Parser |
protected int | $_lineCount | Total number of lines in file | from CRM_Contribute_Import_Parser |
protected int | $_validSoftCreditRowCount | Running total number of valid soft credit rows | from CRM_Contribute_Import_Parser |
protected int | $_invalidSoftCreditRowCount | Running total number of invalid soft credit rows | from CRM_Contribute_Import_Parser |
protected int | $_validPledgePaymentRowCount | Running total number of valid pledge payment rows | from CRM_Contribute_Import_Parser |
protected int | $_invalidPledgePaymentRowCount | Running total number of invalid pledge payment rows | from CRM_Contribute_Import_Parser |
protected array | $_pledgePaymentErrors | Array of pledge payment error lines, bounded by MAX_ERROR | from CRM_Contribute_Import_Parser |
protected array | $_softCreditErrors | Array of pledge payment error lines, bounded by MAX_ERROR | from CRM_Contribute_Import_Parser |
protected string | $_pledgePaymentErrorsFileName | Filename of pledge payment error data | from CRM_Contribute_Import_Parser |
protected string | $_softCreditErrorsFileName | Filename of soft credit error data | from CRM_Contribute_Import_Parser |
protected bool | $_haveColumnHeader | Whether the file has a column header or not | from CRM_Contribute_Import_Parser |
protected | $_mapperKeys | ||
protected | $_mapperSoftCredit | ||
protected array | $_newContributions | Array of successfully imported contribution id's |
Methods
Get metadata for all importable fields in std getfields style format.
Set metadata for all importable fields in std getfields style format.
Class constructor.
The initializer code, called before the processing
The initializer code, called before the processing.
Handle the values in mapField mode.
Handle the values in preview mode.
Handle the values in summary mode.
Handle the values in import mode.
Set and validate field values.
Format the field values for input to the api.
Add progress bar to the import process. Calculates time remaining, status etc.
Remove single-quote enclosures from a value array (row).
Determines the file extension based on error code.
Determines the file name based on error code.
Check if contact is a duplicate .
Parse a field which could be represented by a label or name value rather than the DB value.
No description
Given a list of the importable field keys that the user has selected set the active fields array to this list
Store the soft credit field information.
Store the soft credit field type information.
No description
Export data to a CSV file.
Process pledge payments.
Get the array of successfully imported contribution id's
Format date fields from input to mysql.
Format input params to suit api handling.
Details
in CRM_Import_Parser at line 155
array
getImportableFieldsMetadata()
Get metadata for all importable fields in std getfields style format.
in CRM_Import_Parser at line 163
setImportableFieldsMetadata(array $importableFieldsMetadata)
Set metadata for all importable fields in std getfields style format.
at line 63
__construct($mapperKeys, array $mapperSoftCredit = [], null $mapperPhoneType = NULL, array $mapperSoftCreditType = [])
Class constructor.
at line 73
init()
The initializer code, called before the processing
at line 529
mixed
fini()
The initializer code, called before the processing.
at line 146
mixed
mapField(array $values)
Handle the values in mapField mode.
at line 159
mixed
preview(array $values)
Handle the values in preview mode.
at line 172
mixed
summary($values)
Handle the values in summary mode.
at line 209
mixed
import($onDuplicate, $values)
Handle the values in import mode.
in CRM_Import_Parser at line 283
int
setActiveFieldValues(array $elements, $erroneousField)
Set and validate field values.
in CRM_Contribute_Import_Parser at line 467
array
getActiveFieldParams()
Format the field values for input to the api.
in CRM_Import_Parser at line 343
NULL|$currTimestamp
progressImport($statusID, bool $startImport = TRUE, $startTimestamp = NULL, $prevTimestamp = NULL, $totalRowCount = NULL)
Add progress bar to the import process. Calculates time remaining, status etc.
in CRM_Import_Parser at line 385
array
getSelectValues()
in CRM_Import_Parser at line 396
array
getSelectTypes()
in CRM_Import_Parser at line 409
array
getHeaderPatterns()
in CRM_Import_Parser at line 422
array
getDataPatterns()
in CRM_Import_Parser at line 438
static void
encloseScrub(array $values, string $enclosure = "'")
Remove single-quote enclosures from a value array (row).
in CRM_Import_Parser at line 455
void
setMaxLinesToProcess(int $max)
Setter function.
in CRM_Contribute_Import_Parser at line 626
static string
errorFileName($type)
Determines the file extension based on error code.
in CRM_Contribute_Import_Parser at line 660
static string
saveFileName($type)
Determines the file name based on error code.
in CRM_Import_Parser at line 541
protected array
checkContactDuplicate(array $formatValues)
Check if contact is a duplicate .
in CRM_Import_Parser at line 563
protected mixed
parsePseudoConstantField(string|int|null $submittedValue, array $fieldSpec)
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.
in CRM_Contribute_Import_Parser at line 135
mixed
run(string $fileName, string $seperator = ',', $mapper, bool $skipColumnHeader = FALSE, int $mode = self::MODE_PREVIEW, int $contactType = self::CONTACT_INDIVIDUAL, int $onDuplicate = self::DUPLICATE_SKIP, int $statusID = NULL, int $totalRowCount = NULL)
in CRM_Contribute_Import_Parser at line 417
setActiveFields(array $fieldKeys)
Given a list of the importable field keys that the user has selected set the active fields array to this list
in CRM_Contribute_Import_Parser at line 439
setActiveFieldSoftCredit(array $elements)
Store the soft credit field information.
This was perhaps done this way on the believe that a lot of code pain was worth it to avoid negligible-cost array iterations. Perhaps we could prioritise readability & maintainability next since we can just work with functions to retrieve data from the metadata.
in CRM_Contribute_Import_Parser at line 455
setActiveFieldSoftCreditType(array $elements)
Store the soft credit field type information.
This was perhaps done this way on the believe that a lot of code pain was worth it to avoid negligible-cost array iterations. Perhaps we could prioritise readability & maintainability next since we can just work with functions to retrieve data from the metadata.
in CRM_Contribute_Import_Parser at line 498
addField(string $name, $title, int $type = CRM_Utils_Type::T_INT, string $headerPattern = '//', string $dataPattern = '//')
in CRM_Contribute_Import_Parser at line 522
set(CRM_Core_Session $store, int $mode = self::MODE_SUMMARY)
Store parser values.
in CRM_Contribute_Import_Parser at line 588
static
exportCSV(string $fileName, array $header, array $data)
Export data to a CSV file.
at line 496
int
processPledgePayments(array $formatted)
Process pledge payments.
at line 522
array
getImportedContributions()
Get the array of successfully imported contribution id's
at line 540
array
formatDateFields(array $params)
Format date fields from input to mysql.
at line 598
formatInput(array $params, array $formatted = [])
Format input params to suit api handling.
Over time all the parts of deprecatedFormatParams and all the parts of the import function on this class that relate to reformatting input should be moved here and tests should be added in CRM_Contribute_Import_Parser_ContributionTest.