You are here

public function GoogleCSESearch::execute in Google Custom Search Engine 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Search/GoogleCSESearch.php \Drupal\google_cse\Plugin\Search\GoogleCSESearch::execute()

Executes the search.

Return value

array A structured list of search results.

Overrides SearchInterface::execute

1 call to GoogleCSESearch::execute()
GoogleCSESearch::buildResults in src/Plugin/Search/GoogleCSESearch.php
Executes the search and builds render arrays for the result items.

File

src/Plugin/Search/GoogleCSESearch.php, line 170

Class

GoogleCSESearch
Handles searching for node entities using the Search module index.

Namespace

Drupal\google_cse\Plugin\Search

Code

public function execute() {
  $keys = $this
    ->getKeywords();

  // @todo $condition is an unused variable verify and remove it.
  $conditions = $this->searchParameters['search_conditions'];
  if ($this->configuration['use_adv']) {
    $response = $this->googlecseservices
      ->service($keys);
    $results = $this->googlecseservices
      ->responseResults($response[0], $keys, $conditions);

    // Allow other modules to alter the keys.
    $this->moduleHandler
      ->alter('google_cse_searched_keys', $keys);

    // Allow other modules to alter the results.
    $this->moduleHandler
      ->alter('google_cse_searched_results', $results);
    return $results;
  }
}