Limit the term lookup by vocabulary.

This commit is contained in:
Michael Stenta 2020-05-11 08:20:35 -04:00
parent 529599244f
commit 580b3f3440
1 changed files with 5 additions and 1 deletions

View File

@ -323,7 +323,11 @@ function farm_api_restws_request_alter(array &$request) {
foreach ($_GET as $field_name => &$filter_value) {
$field_info = field_info_field($field_name);
if ($field_info['type'] == 'taxonomy_term_reference' && !is_numeric($filter_value)) {
if ($term = taxonomy_get_term_by_name($filter_value)) {
$vocabulary = NULL;
if (!empty($field_info['settings']['allowed_values'][0]['vocabulary'])) {
$vocabulary = $field_info['settings']['allowed_values'][0]['vocabulary'];
}
if ($term = taxonomy_get_term_by_name($filter_value, $vocabulary)) {
$term = reset($term);
$_GET[$field_name] = $term->tid;
}