public function ResultSet::getSortLinks in Google Search Appliance 8
Returns an array of sort links.
Return value
array Sort links.
File
- src/
SearchResults/ ResultSet.php, line 398
Class
- ResultSet
- Defines a value object for a search response.
Namespace
Drupal\google_appliance\SearchResultsCode
public function getSortLinks() {
$links = [];
if ($this->query
->getSort() === SearchQuery::ORDER_DATE) {
$links[] = Link::fromTextAndUrl($this
->t('Relevance'), Url::fromRoute(SearchViewRoute::ROUTE_NAME, [
'search_query' => $this->query
->getSearchQuery(),
'result_sort' => 'rel',
])
->setAbsolute()
->setOption('query', [
'page' => (string) $this->query
->getPage(),
]));
$links[] = $this
->t('Date');
return $links;
}
$links[] = $this
->t('Relevance');
$links[] = Link::fromTextAndUrl($this
->t('Date'), Url::fromRoute(SearchViewRoute::ROUTE_NAME, [
'search_query' => $this->query
->getSearchQuery(),
'result_sort' => 'date',
])
->setAbsolute()
->setOption('query', [
'page' => (string) $this->query
->getPage(),
]));
return $links;
}