class ManageDialog in TacJS 8.5
Same name and namespace in other branches
- 8.6 src/Form/Steps/ManageDialog.php \Drupal\tacjs\Form\Steps\ManageDialog
- 8.3 src/Form/Steps/ManageDialog.php \Drupal\tacjs\Form\Steps\ManageDialog
- 8.4 src/Form/Steps/ManageDialog.php \Drupal\tacjs\Form\Steps\ManageDialog
Class ManageDialog.
@package Drupal\tacjs\Form
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\tacjs\Form\Steps\ManageDialog
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of ManageDialog
1 string reference to 'ManageDialog'
File
- src/
Form/ Steps/ ManageDialog.php, line 13
Namespace
Drupal\tacjs\Form\StepsView source
class ManageDialog extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'tacjs_manage_dialog';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'tacjs.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('tacjs.settings');
$form['privacyUrl'] = [
'#type' => 'textfield',
'#title' => $this
->t('Privacy url'),
'#description' => $this
->t('Privacy policy url'),
'#default_value' => $config
->get('dialog.privacyUrl'),
];
$form['hashtag'] = [
'#type' => 'textfield',
'#title' => $this
->t('Hashtag'),
'#description' => $this
->t('Open the panel with this hashtag'),
'#default_value' => $config
->get('dialog.hashtag'),
];
$form['cookieName'] = [
'#type' => 'textfield',
'#title' => $this
->t('Cookie name'),
'#default_value' => $config
->get('dialog.cookieName'),
'#required' => TRUE,
];
$form['orientation'] = [
'#type' => 'radios',
'#title' => $this
->t('Orientation'),
'#description' => $this
->t('Banner position (top - bottom)'),
'#default_value' => $config
->get('dialog.orientation'),
'#options' => [
'top' => $this
->t('Top'),
'middle' => $this
->t('Middle'),
'bottom' => $this
->t('Bottom'),
],
];
$form['bodyPosition'] = [
'#type' => 'radios',
'#title' => $this
->t('Body position'),
'#description' => $this
->t('Body position (top - bottom)'),
'#default_value' => $config
->get('dialog.bodyPosition'),
'#options' => [
'top' => $this
->t('Top'),
'bottom' => $this
->t('Bottom'),
],
];
$form['showAlertSmall'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show alert small'),
'#description' => $this
->t('Show the small banner on bottom right'),
'#default_value' => $config
->get('dialog.showAlertSmall'),
];
$form['cookieslist'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Cookies list'),
'#description' => $this
->t('Show the cookie list'),
'#default_value' => $config
->get('dialog.cookieslist'),
];
$form['showIcon'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show Icon'),
'#description' => $this
->t('Show cookie icon to manage cookies'),
'#default_value' => $config
->get('dialog.showIcon'),
];
$form['iconPosition'] = [
'#type' => 'radios',
'#title' => $this
->t('Icon position'),
'#description' => $this
->t('Position of the icon between BottomRight, BottomLeft, TopRight and TopLeft'),
'#default_value' => $config
->get('dialog.iconPosition'),
'#options' => [
'BottomRight' => $this
->t('BottomRight'),
'BottomLeft' => $this
->t('BottomLeft'),
'TopRight' => $this
->t('TopRight'),
'TopLeft' => $this
->t('TopLeft'),
],
];
$form['adblocker'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Adblocker'),
'#description' => $this
->t('Show a Warning if an adblocker is detected'),
'#default_value' => $config
->get('dialog.adblocker'),
];
$form['DenyAllCta'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Deny all cta'),
'#description' => $this
->t('Show the deny all button'),
'#default_value' => $config
->get('dialog.AcceptAllCta'),
];
$form['AcceptAllCta'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Accept all cta'),
'#description' => $this
->t('Show the accept all button when high privacy on'),
'#default_value' => $config
->get('dialog.AcceptAllCta'),
];
$form['highPrivacy'] = [
'#type' => 'checkbox',
'#title' => $this
->t('High privacy'),
'#description' => $this
->t('Disable auto consent'),
'#default_value' => $config
->get('dialog.highPrivacy'),
];
$form['handleBrowserDNTRequest'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Handle browser DNT request'),
'#description' => $this
->t('If Do Not Track == 1, disallow all'),
'#default_value' => $config
->get('dialog.handleBrowserDNTRequest'),
];
$form['removeCredit'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Remove credit'),
'#description' => $this
->t('Remove credit link'),
'#default_value' => $config
->get('dialog.removeCredit'),
];
$form['moreInfoLink'] = [
'#type' => 'checkbox',
'#title' => $this
->t('More info link'),
'#description' => $this
->t('Show more info link'),
'#default_value' => $config
->get('dialog.moreInfoLink'),
];
$form['useExternalCss'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use external CSS'),
'#default_value' => $config
->get('dialog.useExternalCss'),
];
$form['useExternalJs'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use external JS'),
'#default_value' => $config
->get('dialog.useExternalJs'),
];
$form['cookieDomain'] = [
'#type' => 'textarea',
'#title' => $this
->t('Cookie domain'),
'#description' => $this
->t('Shared cookie for subdomain website'),
'#default_value' => $config
->get('dialog.cookieDomain'),
];
$form['readmoreLink'] = [
'#type' => 'textfield',
'#title' => $this
->t('Read more link'),
'#description' => $this
->t('Change the default readmore link pointing to opt-out.ferank.eu'),
'#default_value' => $config
->get('dialog.readmoreLink'),
];
$form['mandatory'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Mandatory'),
'#default_value' => $config
->get('dialog.mandatory'),
];
$form['advanced'] = [
'#type' => 'details',
'#title' => $this
->t('Advanced'),
];
$form['advanced']['expire'] = [
'#type' => 'number',
'#title' => $this
->t('Expiration time'),
'#default_value' => $config
->get('expire'),
'#field_suffix' => ' ' . t('day(s)'),
'#min' => 1,
'#max' => 365,
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state
->setValue('showAlertSmall', $form_state
->getValue('showAlertSmall') ? TRUE : FALSE)
->setValue('cookieslist', $form_state
->getValue('cookieslist') ? TRUE : FALSE)
->setValue('showIcon', $form_state
->getValue('showIcon') ? TRUE : FALSE)
->setValue('adblocker', $form_state
->getValue('adblocker') ? TRUE : FALSE)
->setValue('DenyAllCta', $form_state
->getValue('DenyAllCta') ? TRUE : FALSE)
->setValue('AcceptAllCta', $form_state
->getValue('AcceptAllCta') ? TRUE : FALSE)
->setValue('highPrivacy', $form_state
->getValue('highPrivacy') ? TRUE : FALSE)
->setValue('handleBrowserDNTRequest', $form_state
->getValue('handleBrowserDNTRequest') ? TRUE : FALSE)
->setValue('removeCredit', $form_state
->getValue('removeCredit') ? TRUE : FALSE)
->setValue('moreInfoLink', $form_state
->getValue('moreInfoLink') ? TRUE : FALSE)
->setValue('useExternalCss', $form_state
->getValue('useExternalCss') ? TRUE : FALSE)
->setValue('useExternalJs', $form_state
->getValue('useExternalJs') ? TRUE : FALSE)
->setValue('mandatory', $form_state
->getValue('mandatory') ? TRUE : FALSE)
->setValue('expire', (int) $form_state
->getValue('expire') ?: NULL);
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('tacjs.settings');
$config
->set('dialog.privacyUrl', $form_state
->getValue('privacyUrl'))
->set('dialog.hashtag', $form_state
->getValue('hashtag'))
->set('dialog.cookieName', $form_state
->getValue('cookieName'))
->set('dialog.orientation', $form_state
->getValue('orientation'))
->set('dialog.bodyPosition', $form_state
->getValue('bodyPosition'))
->set('dialog.showAlertSmall', $form_state
->getValue('showAlertSmall'))
->set('dialog.cookieslist', $form_state
->getValue('cookieslist'))
->set('dialog.showIcon', $form_state
->getValue('showIcon'))
->set('dialog.iconPosition', $form_state
->getValue('iconPosition'))
->set('dialog.adblocker', $form_state
->getValue('adblocker'))
->set('dialog.DenyAllCta', $form_state
->getValue('DenyAllCta'))
->set('dialog.AcceptAllCta', $form_state
->getValue('AcceptAllCta'))
->set('dialog.highPrivacy', $form_state
->getValue('highPrivacy'))
->set('dialog.handleBrowserDNTRequest', $form_state
->getValue('handleBrowserDNTRequest'))
->set('dialog.removeCredit', $form_state
->getValue('removeCredit'))
->set('dialog.moreInfoLink', $form_state
->getValue('moreInfoLink'))
->set('dialog.useExternalCss', $form_state
->getValue('useExternalCss'))
->set('dialog.useExternalJs', $form_state
->getValue('useExternalJs'))
->set('dialog.cookieDomain', $form_state
->getValue('cookieDomain'))
->set('dialog.readmoreLink', $form_state
->getValue('readmoreLink'))
->set('dialog.mandatory', $form_state
->getValue('mandatory'))
->set('expire', $form_state
->getValue('expire'))
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
ManageDialog:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
ManageDialog:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
ManageDialog:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
ManageDialog:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
ManageDialog:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |