You are here

public function GoogleCSEServices::advancedSettings in Google Custom Search Engine 8.2

Same name and namespace in other branches
  1. 8.3 src/GoogleCSEServices.php \Drupal\google_cse\GoogleCSEServices::advancedSettings()

Returns an array of any advanced settings which have been set.

File

src/GoogleCSEServices.php, line 509

Class

GoogleCSEServices
Additional functions as services for Google CSE.

Namespace

Drupal\google_cse

Code

public function advancedSettings() {
  $language = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $settings = array();
  foreach (array(
    'cr',
    'gl',
    'hl',
    'ie',
    'lr',
    'oe',
    'safe',
  ) as $parameter) {
    if ($setting = $this->CSEconfig
      ->get('configuration')[$parameter]) {
      $settings[$parameter] = $setting;
    }
  }
  if ($this->CSEconfig
    ->get('configuration')['locale_hl']) {
    $settings['hl'] = $language;
  }
  if ($this->CSEconfig
    ->get('configuration')['locale_lr']) {
    $settings['lr'] = 'lang_' . $language;
  }
  return $settings;
}