protected function Search::findResults in Google Site Search 8
Queries to find search results, and sets status messages.
This method can assume that $this->isSearchExecutable() has already been checked and returned TRUE.
Return value
array|null Results from search query execute() method, or NULL if the search failed.
1 call to Search::findResults()
- Search::execute in src/
Plugin/ Search/ Search.php - Executes the search.
File
- src/
Plugin/ Search/ Search.php, line 345
Class
- Search
- Handles search using Google Search Engine.
Namespace
Drupal\gss\Plugin\SearchCode
protected function findResults($page) {
$items = [];
$page_size = $this->configuration['page_size'];
// Reconcile items per page with api max 10.
$count = 0;
$n = $page_size < self::MAX_NUM ? $page_size : self::MAX_NUM;
for ($i = 0; $i < $page_size; $i += self::MAX_NUM) {
$offset = $page * $page_size + $i;
if (!($response = $this
->getResults($n, $offset))) {
break;
}
if (isset($response->items)) {
$this->count = $response->searchInformation->totalResults;
$items = array_merge($items, $response->items);
}
else {
break;
}
if ($this->configuration['labels'] && !empty($response->context->facets)) {
$this->labels = $response->context->facets;
}
}
return $items;
}