You are here

public function Search::execute in Google Site Search 8

Executes the search.

Return value

array A structured list of search results.

Overrides SearchInterface::execute

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

File

src/Plugin/Search/Search.php, line 311

Class

Search
Handles search using Google Search Engine.

Namespace

Drupal\gss\Plugin\Search

Code

public function execute() {
  if ($this
    ->isSearchExecutable()) {
    $page = pager_find_page();
    $results = $this
      ->findResults($page);

    // API total results is unreliable. Sometimes when requesting a large
    // offset we get no results, and
    // $response->searchInformation->totalResults is 0. In this case return
    // the previous page's items.
    while ($page && !count($results)) {
      $results = $this
        ->findResults(--$page);
    }
    pager_default_initialize($this->count, $this->configuration['page_size']);
    if ($results) {
      return $this
        ->prepareResults($results);
    }
  }
  return array();
}