class EditTexts in TacJS 8.2
Same name and namespace in other branches
- 8.6 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
- 8.3 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
- 8.4 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
- 8.5 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
Class EditTexts.
@package Drupal\tacjs\Form
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\tacjs\Form\Steps\EditTexts
Expanded class hierarchy of EditTexts
1 string reference to 'EditTexts'
File
- src/
Form/ Steps/ EditTexts.php, line 14
Namespace
Drupal\tacjs\Form\StepsView source
class EditTexts extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'tacjs_edit_texts';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = \Drupal::getContainer()
->get('config.factory')
->getEditable('tacjs.settings');
$texts = [
[
'id' => 'adblock',
'msg' => 'Hello! This site is transparent and lets you chose the 3rd party services you want to allow.',
],
[
'id' => 'adblock_call',
'msg' => 'Please disable your adblocker to start customizing.',
],
[
'id' => 'reload',
'msg' => 'Refresh the page',
],
[
'id' => 'alertBigScroll',
'msg' => 'By continuing to scroll,',
],
[
'id' => 'alertBigClick',
'msg' => 'If you continue to browse this website,',
],
[
'id' => 'alertBig',
'msg' => 'you are allowing all third-party services',
],
[
'id' => 'alertBigPrivacy',
'msg' => 'This site uses cookies and gives you control over what you want to activate',
],
[
'id' => 'alertSmall',
'msg' => 'Manage services',
],
[
'id' => 'personalize',
'msg' => 'Personalize',
],
[
'id' => 'acceptAll',
'msg' => 'OK, accept all',
],
[
'id' => 'close',
'msg' => 'Close',
],
[
'id' => 'privacyUrl',
'msg' => 'Privacy policy',
],
[
'id' => 'all',
'msg' => 'Preference for all services',
],
[
'id' => 'info',
'msg' => 'Protecting your privacy',
],
[
'id' => 'disclaimer',
'msg' => 'By allowing these third party services, you accept their cookies and the use of tracking technologies necessary for their proper functioning.',
],
[
'id' => 'allow',
'msg' => 'Allow',
],
[
'id' => 'deny',
'msg' => 'Deny',
],
[
'id' => 'noCookie',
'msg' => 'This service does not use cookie.',
],
[
'id' => 'useCookie',
'msg' => 'This service can install',
],
[
'id' => 'useCookieCurrent',
'msg' => 'This service has installed',
],
[
'id' => 'useNoCookie',
'msg' => 'This service has not installed any cookie.',
],
[
'id' => 'more',
'msg' => 'Read more',
],
[
'id' => 'source',
'msg' => 'View the official website',
],
[
'id' => 'credit',
'msg' => 'Cookies manager by tarteaucitron.js',
],
[
'id' => 'toggleInfoBox',
'msg' => 'Show/hide informations about cookie storage',
],
[
'id' => 'title',
'msg' => 'Cookies management panel',
],
[
'id' => 'cookieDetail',
'msg' => 'Cookie detail for',
],
[
'id' => 'ourSite',
'msg' => 'on our site',
],
[
'id' => 'newWindow',
'msg' => '(new window)',
],
[
'id' => 'allowAll',
'msg' => 'Allow all cookies',
],
[
'id' => 'denyAll',
'msg' => 'Deny all cookies',
],
[
'id' => 'fallback',
'msg' => 'is disabled.',
],
[
'id' => 'ads_title',
'msg' => 'Advertising network',
],
[
'id' => 'ads_details',
'msg' => 'Ad networks can generate revenue by selling advertising space on the site.',
],
[
'id' => 'analytic_title',
'msg' => 'Audience measurement',
],
[
'id' => 'analytic_details',
'msg' => 'The audience measurement services used to generate useful statistics attendance to improve the site.',
],
[
'id' => 'social_title',
'msg' => 'Social networks',
],
[
'id' => 'social_details',
'msg' => 'Social networks can improve the usability of the site and help to promote it via the shares.',
],
[
'id' => 'video_title',
'msg' => 'Videos',
],
[
'id' => 'video_details',
'msg' => 'Video sharing services help to add rich media on the site and increase its visibility.',
],
[
'id' => 'comment_title',
'msg' => 'Comments',
],
[
'id' => 'comment_details',
'msg' => 'Comments managers facilitate the filing of comments and fight against spam.',
],
[
'id' => 'support_title',
'msg' => 'Support',
],
[
'id' => 'support_details',
'msg' => 'Support services allow you to get in touch with the site team and help to improve it.',
],
[
'id' => 'api_title',
'msg' => 'APIs',
],
[
'id' => 'api_details',
'msg' => 'APIs are used to load scripts, geolocation, search engines, translations, ...',
],
[
'id' => 'other_title',
'msg' => 'Other',
],
[
'id' => 'other_details',
'msg' => 'Services to display web content.',
],
];
$form['texts'] = [
'#prefix' => '<p>' . t('Enter the text that will be presented to your website users. The same text is used in both the cookie declaration and the consent dialog.') . '<br />' . t('Translate the text on the <a href=":translate">User interface translation</a> page.', [
':translate' => Url::fromRoute('locale.translate_page')
->toString(),
]) . '</p>',
'#type' => 'table',
'#header' => [
'original' => $this
->t('Original'),
'destination' => $this
->t('Destination'),
],
'#rows' => [],
];
for ($i = 0; $i < count($texts); $i++) {
$form['texts'][$i] = [
'original' => [
'#type' => 'inline_template',
'#template' => '<strong>{{ msg }}</strong>',
'#context' => [
'msg' => $texts[$i]['msg'],
],
],
'destination' => [
'#type' => 'textarea',
'#title' => t('Destination'),
'#title_display' => 'invisible',
'#default_value' => $config
->get('texts.' . $texts[$i]['id']),
],
];
}
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = \Drupal::getContainer()
->get('config.factory')
->getEditable('tacjs.settings');
$texts = [
'adblock',
'adblock_call',
'reload',
'alertBigScroll',
'alertBigClick',
'alertBig',
'alertBigPrivacy',
'alertSmall',
'personalize',
'acceptAll',
'close',
'privacyUrl',
'all',
'info',
'disclaimer',
'allow',
'deny',
'noCookie',
'useCookie',
'useCookieCurrent',
'useNoCookie',
'more',
'source',
'credit',
'toggleInfoBox',
'title',
'cookieDetail',
'ourSite',
'newWindow',
'allowAll',
'denyAll',
'fallback',
'ads_title',
'ads_details',
'analytic_title',
'analytic_details',
'social_title',
'social_details',
'video_title',
'video_details',
'comment_title',
'comment_details',
'support_title',
'support_details',
'api_title',
'api_details',
'other_title',
'other_details',
];
for ($i = 0; $i < count($texts); $i++) {
$config
->set('texts.' . $texts[$i], $form_state
->getValue('texts')[$i]['destination']);
}
$config
->save();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 | |
EditTexts:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
EditTexts:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
EditTexts:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
87 |
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. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
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. | |
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. |