function uif_plus_get_entityreference_value in User Import Framework Plus 7
Helper function to process data for fields provided by the entityreference module.
1 string reference to 'uif_plus_get_entityreference_value'
- uif_plus_uif_supported_fields in ./
uif_plus.module - Implements hook_uif_supported_fields().
File
- ./
uif_plus.module, line 365 - Advanced user import from a CSV file.
Code
function uif_plus_get_entityreference_value($account, $field_info, $value) {
if (uif_is_natural($value)) {
return $value;
}
switch ($field_info['settings']['target_type']) {
case 'node':
$table = $field_info['foreign keys'][$field_info['settings']['target_type']]['table'];
$column = $field_info['foreign keys'][$field_info['settings']['target_type']]['columns']['target_id'];
$types = array_keys($field_info['settings']['handler_settings']['target_bundles']);
$entity_id = db_select($table, 'n')
->extend('PagerDefault')
->fields('n', array(
$column,
))
->condition('n.type', $types, 'IN')
->condition('n.title', $value)
->limit(1)
->execute()
->fetchField();
return $entity_id;
case 'user':
// TODO: email or username
return $value;
}
return $value;
}