You are here

function data_search_views_data_alter in Data 7

Same name and namespace in other branches
  1. 8 data_search/data_search.module \data_search_views_data_alter()
  2. 6 data_search/data_search.module \data_search_views_data_alter()

Implements hook_views_data_alter().

File

data_search/data_search.module, line 50

Code

function data_search_views_data_alter(&$data) {
  $tables = data_search_get_tables();
  foreach ($tables as $table) {
    $name = $table
      ->get('name');
    $schema = $table
      ->get('table_schema');
    $base_field = current($schema['primary key']);

    // Explain how the search index joins to data tables.
    $data['search_index']['table']['join'][$name] = array(
      'left_field' => $base_field,
      'field' => 'sid',
    );
    $data['search_dataset']['table']['join'][$name] = array(
      'left_table' => 'search_index',
      'left_field' => 'sid',
      'field' => 'sid',
      'extra' => 'search_index.type = search_dataset.type',
      'type' => 'INNER',
    );
  }
}