class SimpleSearchFormLazyBuilder in Simple search form 8
Service for build a simple search form.
Hierarchy
- class \Drupal\simple_search_form\SimpleSearchFormLazyBuilder implements TrustedCallbackInterface
Expanded class hierarchy of SimpleSearchFormLazyBuilder
1 string reference to 'SimpleSearchFormLazyBuilder'
1 service uses SimpleSearchFormLazyBuilder
File
- src/
SimpleSearchFormLazyBuilder.php, line 13
Namespace
Drupal\simple_search_formView source
class SimpleSearchFormLazyBuilder implements TrustedCallbackInterface {
/**
* The form builder service.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* Constructs a new SimpleSearchFormLazyBuilder object.
*
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder service.
*/
public function __construct(FormBuilderInterface $form_builder) {
$this->formBuilder = $form_builder;
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'getForm',
];
}
/**
* Lazy builder callback to build the form.
*
* @param string $config
* Simple search form configuration JSON.
*
* @return array
* A render-able form array.
*/
public function getForm($config) {
$config = Json::decode($config);
$form = $this->formBuilder
->getForm(SimpleSearchForm::class, $config);
// Vary caching of this block per selected $_GET parameter when decided
// to use "Keep value in search input after form submit" feature.
if ($config['input_keep_value']) {
$form['#cache']['contexts'][] = 'url.query_args:' . $config['get_parameter'];
}
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SimpleSearchFormLazyBuilder:: |
protected | property | The form builder service. | |
SimpleSearchFormLazyBuilder:: |
public | function | Lazy builder callback to build the form. | |
SimpleSearchFormLazyBuilder:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
SimpleSearchFormLazyBuilder:: |
public | function | Constructs a new SimpleSearchFormLazyBuilder object. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |