public function Search::getSearchOptions in Google Site Search 8
Gets render array for search option links.
File
- src/
Plugin/ Search/ Search.php, line 630
Class
- Search
- Handles search using Google Search Engine.
Namespace
Drupal\gss\Plugin\SearchCode
public function getSearchOptions(Request $request) {
$options = [];
if ($this->configuration['images']) {
$query = $this
->getParameters();
$active = $query['type'] == 'image';
$query['type'] = 'image';
$url = Url::createFromRequest($request);
$url
->setOption('query', $query);
$url
->setOption('attributes', $active ? [
'class' => [
'is-active',
],
] : []);
$options['images'] = [
'#title' => $this
->t('Images'),
'#type' => 'link',
'#url' => $url,
];
}
if (count($options)) {
$query = $this
->getParameters();
$active = empty($query['type']);
if (!$active) {
unset($query['type']);
}
$url = Url::createFromRequest($request);
$url
->setOption('query', $query);
$url
->setOption('attributes', $active ? [
'class' => [
'is-active',
],
] : []);
$options['all'] = [
'#title' => $this
->t('All'),
'#type' => 'link',
'#url' => $url,
'#weight' => -1,
];
return [
'#theme' => 'item_list',
'#items' => $options,
];
}
return [];
}