cache_url_query_ignore-1.0.0-rc1/src/Form/UrlCacheQueryIgnoreSettings.php
src/Form/UrlCacheQueryIgnoreSettings.php
<?php
declare(strict_types=1);
namespace Drupal\cache_url_query_ignore\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\RedundantEditableConfigNamesTrait;
/**
* Module settings form.
*/
class UrlCacheQueryIgnoreSettings extends ConfigFormBase {
use RedundantEditableConfigNamesTrait;
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return 'cache_url_query_ignore_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form = parent::buildForm($form, $form_state);
$form['query_parameters'] = [
'#type' => 'textarea',
'#title' => $this->t('Query parameters'),
'#required' => TRUE,
'#description' => $this->t('List of query parameters to exclude or include (one parameter per line).'),
'#config_target' => 'cache_url_query_ignore.settings:query_parameters',
];
$form['ignore_action'] = [
'#type' => 'radios',
'#title' => $this->t('Ignore action'),
'#required' => TRUE,
'#options' => [
'exclude' => $this->t('Exclude these query parameters from cache key'),
'include' => $this->t('Include only these query parameters in the cache key'),
],
'#config_target' => 'cache_url_query_ignore.settings:ignore_action',
];
return $form;
}
}
