class CiviCrmCustomFields in CRM Core 7
Hierarchy
- class \CRMCoreConversionHandler
- class \CiviCrmCustomFields
Expanded class hierarchy of CiviCrmCustomFields
1 string reference to 'CiviCrmCustomFields'
- CiviCrmCustomFields.inc in modules/
crm_core_data_import/ plugins/ conversion/ CiviCrmCustomFields.inc
File
- modules/
crm_core_data_import/ plugins/ conversion/ CiviCrmCustomFields.inc, line 14
View source
class CiviCrmCustomFields extends CRMCoreConversionHandler {
/**
* Returns array of source plugins compatible with this object.
*/
public function compatible() {
return array(
'CivicrmDataSourceHandler',
);
}
/**
* Process row of data.
*/
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)) {
// @see civicrm/CRM/Core/BAO/CustomField.php - CRM_Core_BAO_CustomField::dataType().
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;
}
}
}
}
}
/**
* Returns TRUE if it is custom field.
*/
public function isCustomField($field) {
return !empty($field['custom_group_id']);
}
/**
* Convert id to value via CiviCRM API.
*/
public function convertConstant($name, $id) {
$value = _crm_core_data_import_civicrm_get_constant($name);
return !empty($value[$id]) ? $value[$id] : FALSE;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CiviCrmCustomFields:: |
public | function |
Returns array of source plugins compatible with this object. Overrides CRMCoreConversionHandler:: |
|
CiviCrmCustomFields:: |
public | function | Convert id to value via CiviCRM API. | |
CiviCrmCustomFields:: |
public | function | Returns TRUE if it is custom field. | |
CiviCrmCustomFields:: |
public | function |
Process row of data. Overrides CRMCoreConversionHandler:: |
|
CRMCoreConversionHandler:: |
public | function | Returns country code for country name. | |
CRMCoreConversionHandler:: |
public | function | Returns field instance. |