Documentation

CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser
in package

Class to parse contribution csv files.

Table of Contents

Constants

PLEDGE_PAYMENT  = 2048
Contribution-specific result codes
PLEDGE_PAYMENT_ERROR  = 4096
Contribution-specific result codes
SOFT_CREDIT  = 512
Contribution-specific result codes
SOFT_CREDIT_ERROR  = 1024
Contribution-specific result codes

Properties

$baseEntity  : mixed

Methods

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.
getRequiredFields()  : array<string|int, mixed>
Get the required fields.
getRequiredFieldsForCreate()  : array<string|int, mixed>
Get required fields to create a contribution.
getRequiredFieldsForMatch()  : array<string|int, mixed>
Get required fields to match a contribution.
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
validateValues()  : void
Validate the import values.
deleteExistingSoftCredit()  : void
getActions()  : array<string|int, mixed>
Get the actions to display in the rich UI.
getFieldMappings()  : array<string|int, mixed>
Get the field mappings for the import.
getOddlyMappedMetadataFields()  : array<string|int, string>
Get the metadata field for which importable fields does not key the actual field name.
getStatus()  : string
Get the status to record.
processNote()  : void
Create or update the note.
removeEmptyValues()  : mixed
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.
lookupMatchingContact()  : int
Lookup matching contact.
processPledgePayments()  : bool
Process pledge payments.

Constants

PLEDGE_PAYMENT

Contribution-specific result codes

public mixed PLEDGE_PAYMENT = 2048
Tags
see
CRM_Import_Parser

result code constants

PLEDGE_PAYMENT_ERROR

Contribution-specific result codes

public mixed PLEDGE_PAYMENT_ERROR = 4096
Tags
see
CRM_Import_Parser

result code constants

SOFT_CREDIT

Contribution-specific result codes

public mixed SOFT_CREDIT = 512
Tags
see
CRM_Import_Parser

result code constants

SOFT_CREDIT_ERROR

Contribution-specific result codes

public mixed SOFT_CREDIT_ERROR = 1024
Tags
see
CRM_Import_Parser

result code constants

Properties

$baseEntity

protected mixed $baseEntity = 'Contribution'

Methods

getImportEntities()

Get a list of entities this import supports.

public getImportEntities() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
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

Return values
string

getMappedRow()

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
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Parameters mapped to CiviCRM fields based on the mapping. eg. [ 'total_amount' => '1230.99', 'financial_type_id' => 1, 'external_identifier' => 'abcd', 'soft_credit' => [3 => ['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>

getRequiredFields()

Get the required fields.

public getRequiredFields() : array<string|int, mixed>
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>

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

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
throws
CRM_Core_Exception

deleteExistingSoftCredit()

protected deleteExistingSoftCredit(int $contributionID) : void
Parameters
$contributionID : int
Tags
throws
CRM_Core_Exception

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>

getFieldMappings()

Get the field mappings for the import.

protected getFieldMappings() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
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
  • entity_data - data about the relevant entity ie ['soft_credit' => ['soft_credit_type_id => 9], 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

getOddlyMappedMetadataFields()

Get the metadata field for which importable fields does not key the actual field name.

protected getOddlyMappedMetadataFields() : array<string|int, string>
Return values
array<string|int, string>

getStatus()

Get the status to record.

protected getStatus(int|null|string $code) : string
Parameters
$code : int|null|string
Return values
string

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
throws
CRM_Core_Exception

removeEmptyValues()

protected removeEmptyValues(mixed $array) : mixed
Parameters
$array : mixed

saveContact()

Save the contact.

protected saveContact(string $entity, array<string|int, mixed> $contact) : int|null
Parameters
$entity : string
$contact : array<string|int, mixed>
Tags
throws
UnauthorizedException|CRM_Core_Exception
Return values
int|null

setFieldMetadata()

Set field metadata.

protected setFieldMetadata() : void

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
todo
  • make this the parent method...
throws
CRM_Core_Exception

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
throws
CRM_Core_Exception

lookupContribution()

Lookup pre-existing contribution ID.

private lookupContribution(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

lookupMatchingContact()

Lookup matching contact.

private lookupMatchingContact(array<string|int, mixed> $params) : int

This looks up the matching contact from the contact id, external identifier or email. For the email a straight email search is done - this is equivalent to what happens on a dedupe rule lookup when the only field is 'email' - but we can't be sure the rule is 'just email' - and we are not collecting the fields for any other lookup in the case of soft credits (if we extend this function to main-contact-lookup we can handle full dedupe lookups - but note the error messages will need tweaking.

Parameters
$params : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
int

Contact ID

processPledgePayments()

Process pledge payments.

private processPledgePayments(int $contributionID, array<string|int, mixed> $formatted) : bool
Parameters
$contributionID : int
$formatted : array<string|int, mixed>
Return values
bool

        
On this page

Search results