You are here

protected static function Utility::modifySolrDynamicFieldName in Search API Solr 8.3

Same name and namespace in other branches
  1. 8.2 src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::modifySolrDynamicFieldName()
  2. 4.x src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::modifySolrDynamicFieldName()

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.

string $pattern: The regex.

string $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 377

Class

Utility
Provides various helper functions for Solr backends.

Namespace

Drupal\search_api_solr\Utility

Code

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