public function CiviCrmCoreFields::prepareRow in CRM Core 7
Process row of data.
Overrides CRMCoreConversionHandler::prepareRow
File
- modules/
crm_core_data_import/ plugins/ conversion/ CiviCrmCoreFields.inc, line 25
Class
Code
public function prepareRow(&$row, $importer) {
foreach ($row as $key => $value) {
$converted_value = NULL;
$civicrm_entity = array();
list($civicrm_entity['type'], $civicrm_entity['bundle'], $civicrm_entity['field'], $civicrm_entity['property'], $civicrm_entity['sub_property']) = explode(':', $key);
switch ($civicrm_entity['field']) {
case 'country':
$converted_value = $this
->countryCode($value);
break;
case 'prefix_id':
$converted_value = $this
->fetchFieldValue('prefix_id', $value, $civicrm_entity['type']);
break;
case 'suffix_id':
$converted_value = $this
->fetchFieldValue('suffix_id', $value, $civicrm_entity['type']);
break;
case 'gender_id':
$converted_value = $this
->fetchFieldValue('gender_id', $value, $civicrm_entity['type']);
break;
case 'priority_id':
$row->{$civicrm_entity['type'] . ':' . $civicrm_entity['bundle'] . ':priority'} = $this
->fetchFieldValue('priority_id', $value, $civicrm_entity['type']);
break;
case 'status_id':
$row->{$civicrm_entity['type'] . ':' . $civicrm_entity['bundle'] . ':status'} = $this
->fetchOptionsValue('activity_status', $value);
break;
case 'email':
if (isset($civicrm_entity['property'])) {
switch ($civicrm_entity['property']) {
case 'location_type_id':
foreach ($value as &$item) {
$item = $this
->fetchLocationType($item);
}
break;
}
$converted_value = $value;
}
break;
case 'website':
if (isset($civicrm_entity['property'])) {
switch ($civicrm_entity['property']) {
case 'website_type_id':
foreach ($value as &$item) {
$item = $this
->fetchOptionsValue('website_type', $item);
}
break;
}
$converted_value = $value;
}
break;
case 'phone':
if (isset($civicrm_entity['property'])) {
switch ($civicrm_entity['property']) {
case 'location_type_id':
foreach ($value as &$item) {
$item = $this
->fetchLocationType($item);
}
break;
case 'phone_type_id':
foreach ($value as &$item) {
$item = $this
->fetchLocationType($item);
}
break;
}
$converted_value = $value;
}
break;
case 'address':
if (isset($civicrm_entity['property'])) {
switch ($civicrm_entity['property']) {
case 'location_type_id':
foreach ($value as &$item) {
$item = $this
->fetchLocationType($item);
}
break;
case 'country_id':
foreach ($value as &$item) {
$item = $this
->fetchCountryById($item);
}
break;
case 'state_province_id':
foreach ($value as &$item) {
$item = $this
->fetchStateById($item);
}
break;
}
$converted_value = $value;
}
break;
// Address location type.
case 'location_type_id':
$converted_value = $this
->fetchLocationType($value);
break;
// Address country ID.
case 'country_id':
$converted_value = $this
->fetchCountryById($value);
break;
// Address state ID.
case 'state_province_id':
$converted_value = $this
->fetchStateById($value);
break;
}
if (!empty($converted_value)) {
$row->{$key} = $converted_value;
}
}
}