ContributionParser
extends ImportParser
in package
Class to parse contribution csv files.
Table of Contents
Properties
- $baseEntity : mixed
Methods
- getAllDedupeRules() : array<string|int, mixed>
- Get all dedupe rules.
- getApplicableBundledActions() : array<string|int, mixed>
- getBundledActions() : array<string|int, mixed>
- getDedupeRule() : array<string|int, mixed>
- Get the dedupe rule, including an array of fields with weights.
- getEntityInstanceConfiguration() : array<string|int, mixed>
- getImportEntities() : array<string|int, mixed>
- Get a list of entities this import supports.
- getMappedFieldLabel() : string
- getMappedRow() : array<string|int, mixed>
- Transform the input parameters into the form handled by the input routine.
- getMappingFieldFromMapperInput() : array<string|int, mixed>
- Get the civicrm_mapping_field appropriate layout for the mapper input.
- getRequiredFieldsForCreate() : array<string|int, mixed>
- Get required fields to create a contribution.
- getRequiredFieldsForMatch() : array<string|int, mixed>
- Get required fields to match a contribution.
- getStaticValuesForEntity() : array<string|int, mixed>
- getUserJobInfo() : array<string|int, mixed>
- Get information about the provided job.
- import() : void
- Handle the values in import mode.
- init() : mixed
- The initializer code, called before the processing
- validateMapping() : void
- Validate that the mapping has the required fields.
- validateValues() : void
- Validate the import values.
- addAction() : mixed
- deleteExistingSoftCredit() : void
- getActions() : array<string|int, mixed>
- Get the actions to display in the rich UI.
- getAllContactFields() : array<string|int, mixed>
- Get all contact import fields metadata.
- getBundledAction() : array<string|int, mixed>|null
- getContactFields() : array<string|int, array<string|int, mixed>>
- getContactID() : int|null
- Get the contact ID for the imported row.
- getDedupeFields() : array<string|int, mixed>
- Get the fields for the dedupe rule.
- getDedupeRuleName() : string
- Get the dedupe rule name.
- getDedupeRules() : array<string|int, mixed>
- Get the dedupe rules to use to lookup a contact.
- getFieldMappings() : array<string|int, mixed>
- Get the field mappings for the import.
- getPossibleMatchesByDedupeRule() : array<string|int, mixed>
- Get contacts that match the input parameters, using a dedupe rule.
- getRequiredFields() : array<string|int, mixed>
- Get the required fields.
- getStatus() : string
- Get the status to record.
- loadRules() : void
- processNote() : void
- Create or update the note.
- saveContact() : int|null
- Save the contact.
- setFieldMetadata() : void
- Set field metadata.
- validateParams() : void
- Override parent to cope with params being separated by entity already.
- deprecatedFormatParams() : void
- take the input parameter list as specified in the data model and convert it into the same format that we use in QF and BAO object
- lookupContribution() : array<string|int, mixed>
- Lookup pre-existing contribution ID.
- processPledgePayments() : bool
- Process pledge payments.
Properties
$baseEntity
protected
mixed
$baseEntity
= 'Contribution'
Methods
getAllDedupeRules()
Get all dedupe rules.
public
getAllDedupeRules() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getApplicableBundledActions()
public
getApplicableBundledActions(string $entity, string $condition) : array<string|int, mixed>
Parameters
- $entity : string
- $condition : string
Tags
Return values
array<string|int, mixed>getBundledActions()
public
static getBundledActions() : array<string|int, mixed>
Return values
array<string|int, mixed>getDedupeRule()
Get the dedupe rule, including an array of fields with weights.
public
getDedupeRule(string|null $contactType[, string|null $name = null ]) : array<string|int, mixed>
The fields are keyed according to the metadata.
Parameters
- $contactType : string|null
- $name : string|null = null
Tags
Return values
array<string|int, mixed>getEntityInstanceConfiguration()
public
getEntityInstanceConfiguration(string $entity) : array<string|int, mixed>
Parameters
- $entity : string
Tags
Return values
array<string|int, mixed>getImportEntities()
Get a list of entities this import supports.
public
getImportEntities() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getMappedFieldLabel()
public
getMappedFieldLabel(array<string|int, mixed> $mappedField) : string
Parameters
- $mappedField : array<string|int, mixed>
-
Field detail as would be saved in field_mapping table or as returned from getMappingFieldFromMapperInput
Tags
Return values
stringgetMappedRow()
Transform the input parameters into the form handled by the input routine.
public
getMappedRow(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
-
Input parameters as they come in from the datasource eg. ['Bob', 'Smith', 'bob@example.org', '123-456']
Tags
Return values
array<string|int, mixed> —Parameters mapped to CiviCRM fields based on the mapping. eg. [ 'Contribution' => [ 'total_amount' => '1230.99', 'financial_type_id' => 1, ], 'Contact' => ['external_identifier' => 'abcd'], 'SoftCreditContact' => ['external_identifier' => '123', 'soft_credit_type_id' => 1]
getMappingFieldFromMapperInput()
Get the civicrm_mapping_field appropriate layout for the mapper input.
public
getMappingFieldFromMapperInput(array<string|int, mixed> $fieldMapping, int $mappingID, int $columnNumber) : array<string|int, mixed>
The input looks something like ['street_address', 1] and would be mapped to ['name' => 'street_address', 'location_type_id' => 1]
Parameters
- $fieldMapping : array<string|int, mixed>
- $mappingID : int
- $columnNumber : int
Return values
array<string|int, mixed>getRequiredFieldsForCreate()
Get required fields to create a contribution.
public
getRequiredFieldsForCreate() : array<string|int, mixed>
Return values
array<string|int, mixed>getRequiredFieldsForMatch()
Get required fields to match a contribution.
public
getRequiredFieldsForMatch() : array<string|int, mixed>
Return values
array<string|int, mixed>getStaticValuesForEntity()
public
getStaticValuesForEntity(string $entity) : array<string|int, mixed>
Parameters
- $entity : string
Tags
Return values
array<string|int, mixed>getUserJobInfo()
Get information about the provided job.
public
static getUserJobInfo() : array<string|int, mixed>
- name
- id (generally the same as name)
- label
e.g. ['activity_import' => ['id' => 'activity_import', 'label' => ts('Activity Import'), 'name' => 'activity_import']]
Return values
array<string|int, mixed>import()
Handle the values in import mode.
public
import(array<string|int, mixed> $values) : void
Parameters
- $values : array<string|int, mixed>
-
The array of values belonging to this line.
init()
The initializer code, called before the processing
public
init() : mixed
Tags
validateMapping()
Validate that the mapping has the required fields.
public
validateMapping(mixed $mapping) : void
Parameters
- $mapping : mixed
Tags
validateValues()
Validate the import values.
public
validateValues(array<string|int, mixed> $values) : void
This overrides the parent to call the hook - cos the other imports are not yet stable enough to add the hook to. If we add the hook to them now and then later switch them to APIv4 style keys we will have to worry about hook consumers.
The values array represents a row in the datasource.
Parameters
- $values : array<string|int, mixed>
Tags
addAction()
protected
addAction(AbstractAction $api, mixed $action, mixed $entityType) : mixed
Parameters
- $api : AbstractAction
- $action : mixed
- $entityType : mixed
deleteExistingSoftCredit()
protected
deleteExistingSoftCredit(int $contributionID) : void
Parameters
- $contributionID : int
Tags
getActions()
Get the actions to display in the rich UI.
protected
getActions(array<string|int, mixed> $actions[, string $entity = 'Contact' ]) : array<string|int, mixed>
Filter by the input actions - e.g ['update' 'select'] will only return those keys.
Parameters
- $actions : array<string|int, mixed>
- $entity : string = 'Contact'
Return values
array<string|int, mixed>getAllContactFields()
Get all contact import fields metadata.
protected
getAllContactFields([string $prefix = 'Contact.' ]) : array<string|int, mixed>
Parameters
- $prefix : string = 'Contact.'
Tags
Return values
array<string|int, mixed>getBundledAction()
protected
getBundledAction(mixed $action, mixed $entityType) : array<string|int, mixed>|null
Parameters
- $action : mixed
- $entityType : mixed
Return values
array<string|int, mixed>|nullgetContactFields()
protected
getContactFields(string|null $contactType[, string|null $prefix = '' ]) : array<string|int, array<string|int, mixed>>
Parameters
- $contactType : string|null
- $prefix : string|null = ''
Tags
Return values
array<string|int, array<string|int, mixed>>getContactID()
Get the contact ID for the imported row.
protected
getContactID(array<string|int, mixed> $contactParams, int|null $contactID, string $entity[, array<string|int, mixed>|null $dedupeRules = null ]) : int|null
If we have a contact ID we check it is valid and, if there is also an external identifier we check it does not conflict.
Failing those we try a dedupe lookup.
Parameters
- $contactParams : array<string|int, mixed>
- $contactID : int|null
- $entity : string
-
Entity, as described in getImportEntities.
- $dedupeRules : array<string|int, mixed>|null = null
-
Dedupe rules to apply (will default to unsupervised rule)
Tags
Return values
int|nullgetDedupeFields()
Get the fields for the dedupe rule.
protected
getDedupeFields(string $contactType) : array<string|int, mixed>
Parameters
- $contactType : string
Return values
array<string|int, mixed>getDedupeRuleName()
Get the dedupe rule name.
protected
getDedupeRuleName(int $id) : string
Parameters
- $id : int
Tags
Return values
stringgetDedupeRules()
Get the dedupe rules to use to lookup a contact.
protected
getDedupeRules(array<string|int, mixed>|null $dedupeRuleNames, string $contact_type) : array<string|int, mixed>
Parameters
- $dedupeRuleNames : array<string|int, mixed>|null
- $contact_type : string
Tags
Return values
array<string|int, mixed>getFieldMappings()
Get the field mappings for the import.
protected
getFieldMappings() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Array of arrays with each array representing a row in the datasource. The arrays hold the following keys
- name - field the row maps to In addition the following are returned but will be phased out.
- contact_type - entity_data but json_encoded. Saved to civicrm_mapping_field in contact_type column
- column_number = this is used for saving to civicrm_field_mapping but may be only legacy now?
- soft_credit_type_id
getPossibleMatchesByDedupeRule()
Get contacts that match the input parameters, using a dedupe rule.
protected
getPossibleMatchesByDedupeRule(array<string|int, mixed> $params, int|null|array<string|int, mixed> $dedupeRuleNames, string $entity) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
- $dedupeRuleNames : int|null|array<string|int, mixed>
- $entity : string
Tags
Return values
array<string|int, mixed>getRequiredFields()
Get the required fields.
protected
getRequiredFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getStatus()
Get the status to record.
protected
getStatus(int|null|string $code) : string
Parameters
- $code : int|null|string
Return values
stringloadRules()
protected
loadRules([array<string|int, mixed> $where = [] ]) : void
Parameters
- $where : array<string|int, mixed> = []
Tags
processNote()
Create or update the note.
protected
processNote(int $contributionID, int $contactID, array<string|int, mixed> $noteParams) : void
Parameters
- $contributionID : int
- $contactID : int
- $noteParams : array<string|int, mixed>
Tags
saveContact()
Save the contact.
protected
saveContact(string $entity, array<string|int, mixed> $contact) : int|null
Parameters
- $entity : string
- $contact : array<string|int, mixed>
Tags
Return values
int|nullsetFieldMetadata()
Set field metadata.
protected
setFieldMetadata() : void
Tags
validateParams()
Override parent to cope with params being separated by entity already.
protected
validateParams(array<string|int, mixed> $params) : void
Parameters
- $params : array<string|int, mixed>
Tags
deprecatedFormatParams()
take the input parameter list as specified in the data model and convert it into the same format that we use in QF and BAO object
private
deprecatedFormatParams(array<string|int, mixed> &$params) : void
Parameters
- $params : array<string|int, mixed>
Tags
lookupContribution()
Lookup pre-existing contribution ID.
private
lookupContribution(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>processPledgePayments()
Process pledge payments.
private
processPledgePayments(int $contributionID, array<string|int, mixed> $formatted) : bool
Parameters
- $contributionID : int
- $formatted : array<string|int, mixed>