You are here

public static function Utility::getLanguageIdFromLanguageSpecificSolrDynamicFieldName in Search API Multilingual Solr Search 8

Extracts the language code from a language-specific dynamic Solr field.

Parameters

string $field_name: The language-specific dynamic Solr field name.

Return value

mixed The Drupal language code as string or boolean FALSE if no language code could be extracted.

2 calls to Utility::getLanguageIdFromLanguageSpecificSolrDynamicFieldName()
AbstractSearchApiSolrMultilingualBackend::alterSolrResponseBody in src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php
@inheritdoc
UtilitiesTest::doDynamicFieldNameConversions in tests/src/Kernel/UtilitiesTest.php
Tests all conversion and extraction functions.

File

src/Utility/Utility.php, line 129

Class

Utility
Provides various helper functions for multilingual Solr backends.

Namespace

Drupal\search_api_solr_multilingual\Utility

Code

public static function getLanguageIdFromLanguageSpecificSolrDynamicFieldName($field_name) {
  $decoded_field_name = SearchApiSolrUtility::decodeSolrName($field_name);
  if (preg_match('@^[a-z]+' . SEARCH_API_SOLR_MULTILINGUAL_LANGUAGE_SEPARATOR . '([^_]+?)_@', $decoded_field_name, $matches)) {
    return $matches[1];
  }
  return FALSE;
}