GSESearchFormBlock.php in Simple Google Custom Search Engine 2.0.x
File
src/Plugin/Block/GSESearchFormBlock.php
View source
<?php
namespace Drupal\simple_gse_search\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\simple_gse_search\Form\SearchForm;
use Symfony\Component\DependencyInjection\ContainerInterface;
class GSESearchFormBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $formBuilder;
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $formBuilder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $formBuilder;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('form_builder'));
}
public function build() {
return $this->formBuilder
->getForm(SearchForm::class);
}
public function getCacheContexts() {
return [
'url',
];
}
}