SearchPage.php in Simple Google Custom Search Engine 2.0.x
File
src/Controller/SearchPage.php
View source
<?php
namespace Drupal\simple_gse_search\Controller;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class SearchPage extends ControllerBase {
protected $searchConfig;
public function __construct(ConfigFactoryInterface $config) {
$this->searchConfig = $config
->get('simple_gse_search.settings');
}
public static function create(ContainerInterface $containerInterface) {
return new static($containerInterface
->get('config.factory'));
}
public function displaySearchResults() {
return [
'#type' => 'html_tag',
'#tag' => 'gcse:searchresults-only',
'#attributes' => [
'queryParameterName' => "s",
'linktarget' => '_parent',
],
'#value' => 'Please make sure javascript is enabled to see the search results.',
'#attached' => [
'library' => [
'simple_gse_search/search',
],
'drupalSettings' => [
'simple_gse_search' => [
'cx' => $this->searchConfig
->get('cx'),
],
],
],
];
}
}
Classes
Name |
Description |
SearchPage |
Defines a controller for displaying search results from Google CSE. |