MembershipParser
extends ImportParser
in package
class to parse membership csv files
Table of Contents
Properties
- $baseEntity : string
- $fieldMetadata : array<string|int, mixed>
- Array of metadata for all available fields.
Methods
- formattedDates() : mixed
- to calculate join, start and end dates
- 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.
- getMappedRow() : array<string|int, mixed>
- Transform the input parameters into the form handled by the input routine.
- getRequiredFields() : array<string|int, mixed>
- Get the required fields.
- getRequiredFieldsForCreate() : array<string|int, mixed>
- Get required fields to create a membership.
- getRequiredFieldsForMatch() : array<string|int, mixed>
- Get required fields to match a membership.
- getStaticValuesForEntity() : array<string|int, mixed>
- getUserJobInfo() : array<string|int, mixed>
- Get information about the provided job.
- import() : int
- Handle the values in import mode.
- validateMapping() : void
- Validate that the mapping has the required fields.
- validateValues() : void
- Validate the values.
- addAction() : mixed
- 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.
- getImportableFields() : array<string|int, mixed>
- getPossibleMatchesByDedupeRule() : array<string|int, mixed>
- Get contacts that match the input parameters, using a dedupe rule.
- loadRules() : void
- saveContact() : int|null
- Save the contact.
- setFieldMetadata() : void
- Set field metadata.
Properties
$baseEntity
protected
string
$baseEntity
= 'Membership'
$fieldMetadata
Array of metadata for all available fields.
protected
array<string|int, mixed>
$fieldMetadata
= []
Methods
formattedDates()
to calculate join, start and end dates
public
formattedDates(array<string|int, mixed> $calcDates, mixed &$formatted) : mixed
Parameters
- $calcDates : array<string|int, mixed>
-
Array of dates returned by getDatesForMembershipType().
- $formatted : mixed
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>
Return values
array<string|int, mixed>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
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]
getRequiredFields()
Get the required fields.
public
getRequiredFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getRequiredFieldsForCreate()
Get required fields to create a membership.
public
getRequiredFieldsForCreate() : array<string|int, mixed>
Return values
array<string|int, mixed>getRequiredFieldsForMatch()
Get required fields to match a membership.
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) : int
Parameters
- $values : array<string|int, mixed>
-
The array of values belonging to this line.
Return values
int —the result of this processing - which is ignored
validateMapping()
Validate that the mapping has the required fields.
public
validateMapping(mixed $mapping) : void
Parameters
- $mapping : mixed
Tags
validateValues()
Validate the values.
public
validateValues(array<string|int, mixed> $values) : void
Parameters
- $values : array<string|int, mixed>
-
The array of values belonging to this line.
Tags
addAction()
protected
addAction(AbstractAction $api, mixed $action, mixed $entityType) : mixed
Parameters
- $api : AbstractAction
- $action : mixed
- $entityType : mixed
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>getImportableFields()
protected
getImportableFields([string $contactType = 'Individual' ]) : array<string|int, mixed>
Parameters
- $contactType : string = 'Individual'
Tags
Return values
array<string|int, mixed>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>loadRules()
protected
loadRules([array<string|int, mixed> $where = [] ]) : void
Parameters
- $where : 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