function entityreference_options_list in Entity reference 7
Same name and namespace in other branches
- 8 entityreference.module \entityreference_options_list()
Implements hook_options_list().
1 call to entityreference_options_list()
- entityreference_views_handler_options_list in views/
entityreference.views.inc - Options callback for Views handler views_handler_filter_in_operator.
File
- ./
entityreference.module, line 811 - Entityreference primary module file.
Code
function entityreference_options_list($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
if (!($options = entityreference_get_selection_handler($field, $instance, $entity_type, $entity)
->getReferencableEntities())) {
return array();
}
// Rebuild the array, by changing the bundle key into the bundle label.
$target_type = $field['settings']['target_type'];
$entity_info = entity_get_info($target_type);
$return = array();
foreach ($options as $bundle => $entity_ids) {
$bundle_label = check_plain($entity_info['bundles'][$bundle]['label']);
$return[$bundle_label] = $entity_ids;
}
return count($return) == 1 ? reset($return) : $return;
}