You are here

function sarnia_field_views_data in Sarnia 7

Implements hook_field_views_data().

File

./sarnia.views.inc, line 6

Code

function sarnia_field_views_data($field) {
  $data = array();
  $field_name = $field['field_name'];
  foreach (array_keys($field['bundles']) as $type_name) {
    if ($entity_type = sarnia_entity_type_load($type_name)) {
      $key = 'search_api_index_' . $entity_type['search_api_index'];
      $instance = field_info_instance($type_name, $field_name, $type_name);
      $data[$key]['table']['base']['defaults']['field'] = 'id';
      $data[$key][$field_name] = array(
        'title' => 'Data',
        'help' => t('Display properties from the %server Sarnia configuration.', array(
          '%server' => $entity_type['search_api_server'],
        )),
        'search_api_index' => $entity_type['search_api_index'],
        'argument' => array(
          'handler' => 'SarniaViewsHandlerArgument',
          'field_name' => $field_name,
          'search_api_index' => $entity_type['search_api_index'],
        ),
        'field' => array(
          'handler' => 'SarniaViewsHandlerField',
          'field_name' => $field_name,
          'search_api_index' => $entity_type['search_api_index'],
        ),
        'filter' => array(
          'handler' => 'SarniaViewsHandlerFilter',
          'field_name' => $field_name,
          'search_api_index' => $entity_type['search_api_index'],
        ),
        'sort' => array(
          'handler' => 'SarniaViewsHandlerSort',
          'field_name' => $field_name,
          'search_api_index' => $entity_type['search_api_index'],
        ),
      );
    }
  }
  return $data;
}