class CRM_Import_ImportProcessor

Class CRM_Import_ImportProcessor.

Import processor class. This is intended to provide a sanitising wrapper around the form-oriented import classes. In particular it is intended to provide a clear translation between the saved mapping field format and the quick form & parser formats.

In the first instance this is only being used in unit tests but the intent is to migrate to it on a trajectory similar to the ExportProcessor so it is not in the tests.

Properties

protected array $mappingFields An array of fields in the format used in the table civicrm_mapping_field.
protected array $metadata
protected array $metadataByTitle Metadata keyed by field title.
protected string $contactType Get contact type being imported.
protected string $contactSubType Get contact sub type being imported.
protected array $validRelationships Array of valid relationships for the contact type & subtype.
protected string $formName Name of the form.
protected int $mappingID Saved Mapping ID.

Methods

string
getFormName()

No description

setFormName(string $formName)

No description

array
getValidRelationships()

No description

setValidRelationships(array $validRelationships)

No description

string
getContactSubType()

Get contact subtype for import.

setContactSubType(string $contactSubType)

Set contact subtype for import.

array
getMetadata()

No description

setMetadata(array $metadata)

Setting for metadata.

int
getMappingID()

No description

setMappingID(int $mappingID)

No description

string
getContactType()

Get the contact type for the import.

setContactType(string $contactType)

No description

setContactTypeByConstant(int $contactTypeKey)

Set the contact type according to the constant.

array
getMappingFields()

Get Mapping Fields.

setMappingFields(array $mappingFields)

Set mapping fields.

getFieldNames()

Get the names of the mapped fields.

string
getFieldName(int $columnNumber)

Get the field name for the given column.

string
getRelationshipKey(int $columnNumber)

Get the field name for the given column.

string|null
getValidRelationshipKey(int $columnNumber)

Get relationship key only if it is valid.

int
getIMProviderID(int $columnNumber)

Get the IM Provider ID.

int
getPhoneTypeID(int $columnNumber)

Get the Phone Type

int
getWebsiteTypeID(int $columnNumber)

Get the Website Type

int
getLocationTypeID(int $columnNumber)

Get the Location Type

int
getPhoneOrIMTypeID(int $columnNumber)

Get the IM or Phone type.

getFieldLocationTypes()

Get the location types of the mapped fields.

getFieldPhoneTypes()

Get the phone types of the mapped fields.

getFieldIMProviderTypes()

Get the names of the im_provider fields.

getFieldWebsiteTypes()

Get the names of the website fields.

getImporterObject()

Get an instance of the importer object.

loadSavedMapping()

Load the mapping from the datbase into the format that would be received from the UI.

getMetadataTitles()

Get the titles from metadata.

array
rekeyBySortedColumnNumbers(array $mappingFields)

Rekey the array by the column_number.

string
getNameFromLabel(string $label)

Get the field name from the label.

bool
isValidRelationshipKey(string $key)

Validate the key against the relationships available for the contatct type & subtype.

string
getQuickFormJSForField(int $column)

Get the relevant js for quickform.

array
getSavedQuickformDefaultsForColumn(int $column)

Get the defaults for the column from the saved mapping.

Details

at line 67
string getFormName()

Return Value

string

at line 74
setFormName(string $formName)

Parameters

string $formName

at line 81
array getValidRelationships()

Return Value

array

at line 97
setValidRelationships(array $validRelationships)

Parameters

array $validRelationships

at line 106
string getContactSubType()

Get contact subtype for import.

Return Value

string

at line 115
setContactSubType(string $contactSubType)

Set contact subtype for import.

Parameters

string $contactSubType

at line 129
array getMetadata()

Return Value

array

at line 143
setMetadata(array $metadata)

Setting for metadata.

We wrangle the label for custom fields to include the label since the metadata trait presents it in a more 'pure' form but the label is appended for importing.

Parameters

array $metadata

Exceptions

CiviCRM_API3_Exception

at line 161
int getMappingID()

Return Value

int

at line 168
setMappingID(int $mappingID)

Parameters

int $mappingID

at line 177
string getContactType()

Get the contact type for the import.

Return Value

string

at line 184
setContactType(string $contactType)

Parameters

string $contactType

at line 193
setContactTypeByConstant(int $contactTypeKey)

Set the contact type according to the constant.

Parameters

int $contactTypeKey

at line 209
array getMappingFields()

Get Mapping Fields.

Return Value

array

Exceptions

CiviCRM_API3_Exception

at line 227
setMappingFields(array $mappingFields)

Set mapping fields.

We do a little cleanup here too.

We ensure that column numbers are set and that the fields are ordered by them.

This would mean the fields could be loaded unsorted.

Parameters

array $mappingFields

at line 246
getFieldNames()

Get the names of the mapped fields.

at line 258
string getFieldName(int $columnNumber)

Get the field name for the given column.

Parameters

int $columnNumber

Return Value

string

Exceptions

CiviCRM_API3_Exception

at line 270
string getRelationshipKey(int $columnNumber)

Get the field name for the given column.

Parameters

int $columnNumber

Return Value

string

Exceptions

CiviCRM_API3_Exception

at line 284
string|null getValidRelationshipKey(int $columnNumber)

Get relationship key only if it is valid.

Parameters

int $columnNumber

Return Value

string|null

Exceptions

CiviCRM_API3_Exception

at line 298
int getIMProviderID(int $columnNumber)

Get the IM Provider ID.

Parameters

int $columnNumber

Return Value

int

Exceptions

CiviCRM_API3_Exception

at line 311
int getPhoneTypeID(int $columnNumber)

Get the Phone Type

Parameters

int $columnNumber

Return Value

int

Exceptions

CiviCRM_API3_Exception

at line 324
int getWebsiteTypeID(int $columnNumber)

Get the Website Type

Parameters

int $columnNumber

Return Value

int

Exceptions

CiviCRM_API3_Exception

at line 339
int getLocationTypeID(int $columnNumber)

Get the Location Type

Returning 0 rather than null is historical.

Parameters

int $columnNumber

Return Value

int

Exceptions

CiviCRM_API3_Exception

at line 354
int getPhoneOrIMTypeID(int $columnNumber)

Get the IM or Phone type.

We have a field that would be the 'relevant' type - which could be either.

Parameters

int $columnNumber

Return Value

int

Exceptions

CiviCRM_API3_Exception

at line 363
getFieldLocationTypes()

Get the location types of the mapped fields.

at line 372
getFieldPhoneTypes()

Get the phone types of the mapped fields.

at line 381
getFieldIMProviderTypes()

Get the names of the im_provider fields.

at line 390
getFieldWebsiteTypes()

Get the names of the website fields.

at line 401
CRM_Contact_Import_Parser_Contact getImporterObject()

Get an instance of the importer object.

at line 428
protected loadSavedMapping()

Load the mapping from the datbase into the format that would be received from the UI.

at line 462
getMetadataTitles()

Get the titles from metadata.

at line 476
protected array rekeyBySortedColumnNumbers(array $mappingFields)

Rekey the array by the column_number.

Parameters

array $mappingFields

Return Value

array

at line 489
protected string getNameFromLabel(string $label)

Get the field name from the label.

Parameters

string $label

Return Value

string

at line 501
protected bool isValidRelationshipKey(string $key)

Validate the key against the relationships available for the contatct type & subtype.

Parameters

string $key

Return Value

bool

at line 513
string getQuickFormJSForField(int $column)

Get the relevant js for quickform.

Parameters

int $column

Return Value

string

Exceptions

CiviCRM_API3_Exception

at line 554
array getSavedQuickformDefaultsForColumn(int $column)

Get the defaults for the column from the saved mapping.

Parameters

int $column

Return Value

array

Exceptions

CiviCRM_API3_Exception