You are here

function _search_api_views_find_field_alias in Search API 8

Finds an unused 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 The field alias to use.

3 calls to _search_api_views_find_field_alias()
search_api_views_data in ./search_api.views.inc
Implements hook_views_data().
_search_api_views_add_handlers_for_properties in ./search_api.views.inc
Adds field and relationship handlers for the given properties.
_search_api_views_data_special_fields in ./search_api.views.inc
Adds definitions for our special fields to a Views data table definition.

File

./search_api.views.inc, line 177
Views hook implementations for the Search API module.

Code

function _search_api_views_find_field_alias($field_id, array &$table) {
  $base = $field_alias = preg_replace('/[^a-zA-Z0-9]+/S', '_', $field_id);
  $i = 0;
  while (isset($table[$field_alias])) {
    $field_alias = $base . '_' . ++$i;
  }
  return $field_alias;
}