Documentation

CRM_Import_ImportProcessor
in package

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.

Table of Contents

Properties

$contactSubType  : string
Get contact sub type being imported.
$contactType  : string
Get contact type being imported.
$formName  : string
Name of the form.
$mappingFields  : array<string|int, mixed>
An array of fields in the format used in the table civicrm_mapping_field.
$mappingID  : int
Saved Mapping ID.
$metadata  : array<string|int, mixed>
$metadataByTitle  : array<string|int, mixed>
Metadata keyed by field title.
$userJobID  : int
Id of the created user job.
$validRelationships  : array<string|int, mixed>
Array of valid relationships for the contact type & subtype.

Methods

convertSavedFields()  : void
This exists for use in the FiveFifty Upgrade
getContactSubType()  : string
Get contact subtype for import.
getContactType()  : string
Get the contact type for the import.
getFieldIMProviderTypes()  : mixed
Get the names of the im_provider fields.
getFieldLocationTypes()  : mixed
Get the location types of the mapped fields.
getFieldName()  : string
Get the field name for the given column.
getFieldNames()  : mixed
Get the names of the mapped fields.
getFieldPhoneTypes()  : mixed
Get the phone types of the mapped fields.
getFieldWebsiteTypes()  : mixed
Get the names of the website fields.
getFormName()  : string
getImporterObject()  : CRM_Contact_Import_Parser_Contact
Get an instance of the importer object.
getIMProviderID()  : int
Get the IM Provider ID.
getLocationTypeID()  : int
Get the Location Type
getMappingFields()  : array<string|int, mixed>
Get Mapping Fields.
getMappingID()  : int
getMetadata()  : array<string|int, mixed>
getMetadataTitles()  : mixed
Get the titles from metadata.
getPhoneOrIMTypeID()  : int
Get the IM or Phone type.
getPhoneTypeID()  : int
Get the Phone Type
getRelationshipKey()  : string
Get the field name for the given column.
getSavedQuickformDefaultsForColumn()  : array<string|int, mixed>
Get the defaults for the column from the saved mapping.
getUserJobID()  : int
getValidRelationshipKey()  : string|null
Get relationship key only if it is valid.
getValidRelationships()  : array<string|int, mixed>
getWebsiteTypeID()  : int
Get the Website Type
isValidField()  : bool
Is the field valid for this import.
setContactSubType()  : mixed
Set contact subtype for import.
setContactType()  : mixed
setContactTypeByConstant()  : mixed
Set the contact type according to the constant.
setFormName()  : mixed
setMappingFields()  : mixed
Set mapping fields.
setMappingID()  : mixed
setMetadata()  : mixed
Setting for metadata.
setUserJobID()  : void
setValidRelationships()  : mixed
getFieldMetadata()  : array<string|int, mixed>
Get the metadata for the field.
getNameFromLabel()  : string
Get the field name from the label.
isValidRelationshipKey()  : bool
Validate the key against the relationships available for the contatct type & subtype.
legacyLoadSavedMapping()  : mixed
Load the mapping from the database into the pre-5.50 format.
loadSavedMapping()  : mixed
Load the mapping from the datbase into the format that would be received from the UI.
rekeyBySortedColumnNumbers()  : array<string|int, mixed>
Rekey the array by the column_number.

Properties

$contactSubType

Get contact sub type being imported.

protected string $contactSubType

$contactType

Get contact type being imported.

protected string $contactType

$formName

Name of the form.

protected string $formName

Used for js for quick form.

$mappingFields

An array of fields in the format used in the table civicrm_mapping_field.

protected array<string|int, mixed> $mappingFields = []

$metadataByTitle

Metadata keyed by field title.

protected array<string|int, mixed> $metadataByTitle = []

$validRelationships

Array of valid relationships for the contact type & subtype.

protected array<string|int, mixed> $validRelationships = []

Methods

getContactSubType()

Get contact subtype for import.

public getContactSubType() : string
Return values
string

getContactType()

Get the contact type for the import.

public getContactType() : string
Return values
string

getFieldName()

Get the field name for the given column.

public getFieldName(int $columnNumber) : string
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
string

getIMProviderID()

Get the IM Provider ID.

public getIMProviderID(int $columnNumber) : int
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
int

getLocationTypeID()

Get the Location Type

public getLocationTypeID(int $columnNumber) : int

Returning 0 rather than null is historical.

Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
int

getMappingFields()

Get Mapping Fields.

public getMappingFields() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getMetadata()

public getMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMetadataTitles()

Get the titles from metadata.

public getMetadataTitles() : mixed

getPhoneOrIMTypeID()

Get the IM or Phone type.

public getPhoneOrIMTypeID(int $columnNumber) : int

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

Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
int

getPhoneTypeID()

Get the Phone Type

public getPhoneTypeID(int $columnNumber) : int
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
int

getRelationshipKey()

Get the field name for the given column.

public getRelationshipKey(int $columnNumber) : string
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
string

getSavedQuickformDefaultsForColumn()

Get the defaults for the column from the saved mapping.

public getSavedQuickformDefaultsForColumn(int $column) : array<string|int, mixed>
Parameters
$column : int
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getValidRelationshipKey()

Get relationship key only if it is valid.

public getValidRelationshipKey(int $columnNumber) : string|null
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
string|null

getValidRelationships()

public getValidRelationships() : array<string|int, mixed>
Return values
array<string|int, mixed>

getWebsiteTypeID()

Get the Website Type

public getWebsiteTypeID(int $columnNumber) : int
Parameters
$columnNumber : int
Tags
throws
CRM_Core_Exception
Return values
int

isValidField()

Is the field valid for this import.

public isValidField(string $fieldName) : bool

If not defined in metadata is is not valid.

Parameters
$fieldName : string
Return values
bool

setContactSubType()

Set contact subtype for import.

public setContactSubType(string $contactSubType) : mixed
Parameters
$contactSubType : string

setContactType()

public setContactType(string $contactType) : mixed
Parameters
$contactType : string

setContactTypeByConstant()

Set the contact type according to the constant.

public setContactTypeByConstant(int $contactTypeKey) : mixed
Parameters
$contactTypeKey : int

setFormName()

public setFormName(string $formName) : mixed
Parameters
$formName : string

setMappingFields()

Set mapping fields.

public setMappingFields(array<string|int, mixed> $mappingFields) : mixed

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
$mappingFields : array<string|int, mixed>

setMappingID()

public setMappingID(int $mappingID) : mixed
Parameters
$mappingID : int

setMetadata()

Setting for metadata.

public setMetadata(array<string|int, mixed> $metadata) : mixed

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
$metadata : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

setUserJobID()

public setUserJobID(int $userJobID) : void
Parameters
$userJobID : int

setValidRelationships()

public setValidRelationships(array<string|int, mixed> $validRelationships) : mixed
Parameters
$validRelationships : array<string|int, mixed>

getFieldMetadata()

Get the metadata for the field.

protected getFieldMetadata(string $fieldName) : array<string|int, mixed>
Parameters
$fieldName : string
Return values
array<string|int, mixed>

getNameFromLabel()

Get the field name from the label.

protected getNameFromLabel(string $label) : string
Parameters
$label : string
Return values
string

isValidRelationshipKey()

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

protected isValidRelationshipKey(string $key) : bool
Parameters
$key : string
Return values
bool

legacyLoadSavedMapping()

Load the mapping from the database into the pre-5.50 format.

protected legacyLoadSavedMapping() : mixed

This is preserved as a copy the upgrade script can use - since the upgrade allows the other to be 'fixed'.

Tags
throws
CRM_Core_Exception

loadSavedMapping()

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

protected loadSavedMapping() : mixed
Tags
throws
CRM_Core_Exception

rekeyBySortedColumnNumbers()

Rekey the array by the column_number.

protected rekeyBySortedColumnNumbers(array<string|int, mixed> $mappingFields) : array<string|int, mixed>
Parameters
$mappingFields : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results