private function BlockerSettingsForm::cookieFormContainer in Cookie Content Blocker 8
Create a container to configure cookie settings.
Parameters
string $type: The type of the event.
Return value
array The event form container.
1 call to BlockerSettingsForm::cookieFormContainer()
- BlockerSettingsForm::buildForm in src/
Form/ BlockerSettingsForm.php - Form constructor.
File
- src/
Form/ BlockerSettingsForm.php, line 172
Class
- BlockerSettingsForm
- Form builder to manage settings related to the Cookie content blocker.
Namespace
Drupal\cookie_content_blocker\FormCode
private function cookieFormContainer(string $type) : array {
$defaults = $this
->config('cookie_content_blocker.settings')
->get('consent_awareness.' . $type . '.cookie') ?? [];
$container = [];
$container['operator'] = [
'#type' => 'select',
'#title' => $this
->t('Cookie comparison operator'),
'#description' => $this
->t('The operator to use to compare the actual cookie value to the configured value'),
'#default_value' => $defaults['operator'] ?? '',
'#empty_option' => $this
->t('- Select -'),
'#options' => $this
->cookieValueOperators(),
'#element_validate' => [
[
$this,
'stripWhitespaces',
],
],
];
$container['name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Cookie name'),
'#description' => $this
->t('The name of the cookie to check for consent.'),
'#default_value' => $defaults['name'] ?? '',
'#element_validate' => [
[
$this,
'stripWhitespaces',
],
],
];
$container['value'] = [
'#type' => 'textfield',
'#title' => $this
->t('Cookie value'),
'#description' => $this
->t('The value to use for comparison.'),
'#default_value' => $defaults['value'] ?? '',
'#element_validate' => [
[
$this,
'stripWhitespaces',
],
],
];
return $container;
}