You are here

public function StreamingExpressionBuilder::_escape_and_implode in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Utility/StreamingExpressionBuilder.php \Drupal\search_api_solr\Utility\StreamingExpressionBuilder::_escape_and_implode()
  2. 8.2 src/Utility/StreamingExpressionBuilder.php \Drupal\search_api_solr\Utility\StreamingExpressionBuilder::_escape_and_implode()

Calls _escaped_value on each array element and returns the imploded result.

Parameters

string $glue: The string to put between the escaped values. This can be used to create an "or" condition from the array of values, for example, by passing the string ' || ' as glue.

array $values: The array of values to escape.

bool $single_term: (optional) Escapes the value as single term if TRUE, otherwise as phrase. Defaults to TRUE.

string $search_api_field_name: (optional) Passed on to _escaped_value(); Influences whether processors act on the values.

Return value

string The imploded string of escaped values.

File

src/Utility/StreamingExpressionBuilder.php, line 424

Class

StreamingExpressionBuilder
Provides methods for creating streaming expressions targeting a given index.

Namespace

Drupal\search_api_solr\Utility

Code

public function _escape_and_implode(string $glue, array $values, $single_term = TRUE, string $search_api_field_name = NULL) {
  $escaped_values = [];
  foreach ($values as $value) {
    $escaped_values[] = $this
      ->_escaped_value($value, $single_term, $search_api_field_name);
  }
  return implode($glue, $escaped_values);
}