You are here

protected function SearchApiQuery::sanitizeFieldId in Search API 8

Adapts a field ID for use in a Search API query.

This method will remove a leading period (.), if present. This is done because in the SQL Views query plugin field IDs are always prefixed with a table alias (in our case always empty) followed by a period.

Parameters

string $field_id: The field ID to adapt for use in the Search API.

Return value

string The sanitized field ID.

2 calls to SearchApiQuery::sanitizeFieldId()
SearchApiQuery::addWhere in src/Plugin/views/query/SearchApiQuery.php
Adds a simple condition to the query.
SearchApiQuery::transformDbCondition in src/Plugin/views/query/SearchApiQuery.php
Transforms a database condition to an equivalent search filter.

File

src/Plugin/views/query/SearchApiQuery.php, line 1198

Class

SearchApiQuery
Defines a Views query class for searching on Search API indexes.

Namespace

Drupal\search_api\Plugin\views\query

Code

protected function sanitizeFieldId($field_id) {
  if ($field_id && $field_id[0] === '.') {
    $field_id = substr($field_id, 1);
  }
  return $field_id;
}