You are here

function _search_api_location_views_get_field_alias in Search API Location 8

Finds the field alias for a field in a Views table definition.

Parameters

string $field_id: The original ID of the Search API field.

array $table: The Views table definition.

Return value

string|false The field alias of the field or FALSE.

1 call to _search_api_location_views_get_field_alias()
search_api_location_views_views_data_alter in modules/search_api_location_views/search_api_location_views.module
Implements hook_views_data_alter().

File

modules/search_api_location_views/search_api_location_views.module, line 60
Provide Views integration for Search API Location.

Code

function _search_api_location_views_get_field_alias($field_id, array $table) {

  // We need to determine the Views field alias based on the Search API
  // field_id.
  // We can't use _search_api_views_find_field_alias, as that would generate
  // a new name.
  $field_alias = FALSE;
  if (isset($table[$field_id])) {
    $field_alias = $field_id;
  }
  else {
    foreach ($table as $field_name => $field_info) {
      if (!empty($field_info['real field']) && $field_info['real field'] == $field_id) {
        $field_alias = $field_name;
        break;
      }
    }
  }
  return $field_alias;
}