You are here

function _google_appliance_get_lr in Google Search Appliance 8

Format the value of the 'lr' parameter appropriately.

Parameters

$options: Array of languages to filter, as defined by the config variable google_appliance_language_filter_options.

Return value

String to be passed to the GSA using the 'lr' parameter.

1 call to _google_appliance_get_lr()
google_appliance_get_clusters in src/Service/Search.php
Get related search via the Google Search Appliance clustering service.

File

src/Service/Search.php, line 244

Namespace

Drupal\google_appliance\Service

Code

function _google_appliance_get_lr($options) {
  $langcodes = [];
  $options = array_filter($options);
  foreach ($options as $option) {
    switch ($option) {
      case '***CURRENT_LANGUAGE***':
        $language = Drupal::languageManager()
          ->getCurrentLanguage();
        $langcode = $language->language;
        break;
      case '***DEFAULT_LANGUAGE***':
        $langcode = language_default('language');
        break;
      default:
        $langcode = $option;
    }
    $langcodes[$langcode] = "lang_{$langcode}";
  }
  return implode('|', $langcodes);
}