You are here

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

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

Returns SiteSearch default value.

1 call to GoogleCSEServices::sitesearchDefault()
GoogleCSEServices::siteSearchForm in src/GoogleCSEServices.php
Returns SiteSearch options form item.

File

src/GoogleCSEServices.php, line 494

Class

GoogleCSEServices
Additional functions as services for Google CSE.

Namespace

Drupal\google_cse

Code

public function sitesearchDefault() {
  $options = $this
    ->sitesearchOptions();
  if ($this->requestStack
    ->getCurrentRequest()->query
    ->has('sitesearch') && isset($options[$this->requestStack
    ->getCurrentRequest()->query
    ->get('sitesearch')])) {
    return $this->requestStack
      ->getCurrentRequest()->query
      ->get('sitesearch');
  }
  elseif ($this->CSEconfig
    ->get('configuration')['sitesearch_default']) {

    // Return the key of the second element in the array.
    return key(array_slice($options, 1, 1));
  }
  return '';
}