function references_dialog_entityreference_views_query in References dialog 7
View query callback for entityreference references.
1 string reference to 'references_dialog_entityreference_views_query'
File
- ./
references_dialog.dialog_widgets.inc, line 334 - Implements dialogs for node reference and user reference fields.
Code
function references_dialog_entityreference_views_query($view, $instance, $field) {
// We need to make sure that no entries that we can't add to our field shows
// up, so we need to limit the data here.
$types = array();
if (!empty($field['settings']['handler_settings']['target_bundles'])) {
$entity_info = entity_get_info($field['settings']['target_type']);
if (isset($entity_info['entity keys']['bundle'])) {
// Taxonomy terms don't have their bundle in the table, so we handle them
// specially, for now.
if ($field['settings']['target_type'] == 'taxonomy_term') {
$table = 'taxonomy_vocabulary';
$column = 'machine_name';
}
else {
$table = $view->base_table;
$column = $entity_info['entity keys']['bundle'];
}
// Add the bundle property as a default.
$view->query
->add_where(0, "{$table}." . $column, array_values($field['settings']['handler_settings']['target_bundles']));
}
}
}