function _ref_field_get_referenceable_entities in (Entity)Reference Field Synchronization 7
Return the labels of referenceable entities matching some criteria.
1 call to _ref_field_get_referenceable_entities()
- ref_field_options_list in ./
ref_field.module - Implements hook_options_list().
File
- ./
ref_field.module, line 690
Code
function _ref_field_get_referenceable_entities($field) {
$options = array();
$entity_type = $field['settings']['entity'];
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', $entity_type);
if ($field['settings']['bundles']) {
switch ($field['settings']['entity']) {
case 'comment':
break;
case 'taxonomy_term':
// Special case for taxonomy_term
// http://api.drupal.org/api/drupal/includes--entity.inc/function/EntityFieldQuery%3A%3AentityCondition/7
$query
->propertyCondition('vid', $field['settings']['bundles'], 'IN');
break;
default:
$query
->entityCondition('bundle', $field['settings']['bundles'], 'IN');
break;
}
}
$results = $query
->execute();
if (!empty($results[$entity_type])) {
$entities = entity_load($entity_type, array_keys($results[$entity_type]));
foreach ($entities as $entity_id => $entity) {
$options[$entity_id] = entity_label($entity_type, $entity);
}
}
return $options;
}