You are here

protected static function Utility::modifySolrDynamicFieldName in Search API Multilingual Solr Search 8

Modifies a dynamic Solr field's name using a regular expression.

If the field name is encoded it will be decoded before the regular expression runs and encoded again before the modified is returned.

Parameters

string $field_name: The dynamic Solr field name.

$pattern: The regex.

$replacement: The replacement for the pattern match.

Return value

string The modified dynamic Solr field name.

See also

Drupal\search_api_solr\Utility\Utility::encodeSolrName()

2 calls to Utility::modifySolrDynamicFieldName()
Utility::getLanguageSpecificSolrDynamicFieldNameForSolrDynamicFieldName in src/Utility/Utility.php
Maps a Solr field name to its language-specific equivalent.
Utility::getSolrDynamicFieldNameForLanguageSpecificSolrDynamicFieldName in src/Utility/Utility.php
Maps a language-specific Solr field name to its unspecific equivalent.

File

src/Utility/Utility.php, line 95

Class

Utility
Provides various helper functions for multilingual Solr backends.

Namespace

Drupal\search_api_solr_multilingual\Utility

Code

protected static function modifySolrDynamicFieldName($field_name, $pattern, $replacement) {
  $decoded_field_name = SearchApiSolrUtility::decodeSolrName($field_name);
  $modified_field_name = preg_replace($pattern, $replacement, $decoded_field_name);
  if ($decoded_field_name != $field_name) {
    $modified_field_name = SearchApiSolrUtility::encodeSolrName($modified_field_name);
  }
  return $modified_field_name;
}