CiviCrmCustomFields.inc in CRM Core 7
File
modules/crm_core_data_import/plugins/conversion/CiviCrmCustomFields.inc
View source
<?php
$plugin = array(
'label' => t('CiviCRM Custom Fields'),
'handler' => array(
'class' => 'CiviCrmCustomFields',
),
);
class CiviCrmCustomFields extends CRMCoreConversionHandler {
public function compatible() {
return array(
'CivicrmDataSourceHandler',
);
}
public function prepareRow(&$row, $importer) {
foreach ($row as $key => $value) {
$civicrm_entity = array();
list($civicrm_entity['type'], $civicrm_entity['bundle'], $civicrm_entity['field']) = explode(':', $key);
$field = $this
->getCiviCrmFieldInstance($civicrm_entity['type'], $civicrm_entity['field']);
if ($this
->isCustomField($field)) {
if (!empty($field['data_type'])) {
switch ($field['data_type']) {
case 'Country':
$row->{$key} = $this
->convertConstant('countryIsoCode', $value);
break;
case 'StateProvince':
$row->{$key} = $this
->convertConstant('stateProvinceAbbreviation', $value);
break;
}
}
}
}
}
public function isCustomField($field) {
return !empty($field['custom_group_id']);
}
public function convertConstant($name, $id) {
$value = _crm_core_data_import_civicrm_get_constant($name);
return !empty($value[$id]) ? $value[$id] : FALSE;
}
}