function _range_views_search_api_data in Range 7
Helper function.
Collects views search API data for range fields.
Parameters
array $data: Views data array.
See also
1 call to _range_views_search_api_data()
- range_views_data in views/
range.views.inc - Implements hook_views_data().
File
- views/
range.views.inc, line 45 - Implementation of Views API.
Code
function _range_views_search_api_data(array &$data) {
foreach (search_api_index_load_multiple(FALSE) as $index) {
$indexed_fields = $index
->getFields();
$wrapper = $index
->entityWrapper(NULL, FALSE);
foreach ($wrapper as $key => $property) {
// Make sure that both FROM and TO values are being indexed.
if ($property
->type() === 'field_item_range' && !empty($indexed_fields["{$key}:from"]['indexed']) && !empty($indexed_fields["{$key}:to"]['indexed'])) {
$info = $property
->info();
$data['search_api_index_' . $index->machine_name][$key]['filter'] = array(
'title' => t('@label range filter', array(
'@label' => $info['label'],
)),
'help' => t('Range contains (or does not contain) a value'),
'handler' => 'range_search_api_handler_filter_numeric_range',
'allow empty' => FALSE,
);
$data['search_api_index_' . $index->machine_name][$key]['argument'] = array(
'title' => t('@label range argument', array(
'@label' => $info['label'],
)),
'help' => t('Range contains (or does not contain) a value'),
'handler' => 'range_search_api_handler_argument_numeric_range',
'empty field name' => t('- No value -'),
'numeric' => TRUE,
);
}
}
}
}