You are here

class EditTexts in TacJS 8.5

Same name and namespace in other branches
  1. 8.6 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
  2. 8.2 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
  3. 8.3 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts
  4. 8.4 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts

Class EditTexts.

@package Drupal\tacjs\Form

Hierarchy

Expanded class hierarchy of EditTexts

1 string reference to 'EditTexts'
tacjs.routing.yml in ./tacjs.routing.yml
tacjs.routing.yml

File

src/Form/Steps/EditTexts.php, line 13

Namespace

Drupal\tacjs\Form\Steps
View source
class EditTexts extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'tacjs_edit_texts';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'tacjs.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('tacjs.settings');
    $form['middleBarHead'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Middle Bar Head'),
      '#default_value' => $config
        ->get('texts.middleBarHead'),
      '#placeholder' => $this
        ->t('☝ 🍪'),
    ];
    $form['adblock'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Adblock'),
      '#default_value' => $config
        ->get('texts.adblock'),
      '#placeholder' => $this
        ->t('Hello! This site is transparent and lets you choose the 3rd party services you want to allow.'),
    ];
    $form['adblock_call'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Adblock Call'),
      '#default_value' => $config
        ->get('texts.adblock_call'),
      '#placeholder' => $this
        ->t('Please disable your adblocker to start customizing.'),
    ];
    $form['reload'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Reload'),
      '#default_value' => $config
        ->get('texts.reload'),
      '#placeholder' => $this
        ->t('Refresh the page'),
    ];
    $form['alertBigScroll'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Alert Big Scroll'),
      '#default_value' => $config
        ->get('texts.alertBigScroll'),
      '#placeholder' => $this
        ->t('By continuing to scroll,'),
    ];
    $form['alertBigClick'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Alert Big Click'),
      '#default_value' => $config
        ->get('texts.alertBigClick'),
      '#placeholder' => $this
        ->t('If you continue to browse this website,'),
    ];
    $form['alertBig'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('AlertBig'),
      '#default_value' => $config
        ->get('texts.alertBig'),
      '#placeholder' => $this
        ->t('you are allowing all third-party services'),
    ];
    $form['alertBigPrivacy'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Alert Big Privacy'),
      '#default_value' => $config
        ->get('texts.alertBigPrivacy'),
      '#placeholder' => $this
        ->t('This site uses cookies and gives you control over what you want to activate'),
    ];
    $form['alertSmall'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Alert Small'),
      '#default_value' => $config
        ->get('texts.alertSmall'),
      '#placeholder' => $this
        ->t('Manage services'),
    ];
    $form['personalize'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Personalize'),
      '#default_value' => $config
        ->get('texts.personalize'),
      '#placeholder' => $this
        ->t('Personalize'),
    ];
    $form['acceptAll'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Accept All'),
      '#default_value' => $config
        ->get('texts.acceptAll'),
      '#placeholder' => $this
        ->t('OK, accept all'),
    ];
    $form['close'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Close'),
      '#default_value' => $config
        ->get('texts.close'),
      '#placeholder' => $this
        ->t('Close'),
    ];
    $form['privacyUrl'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Privacy Url'),
      '#default_value' => $config
        ->get('texts.privacyUrl'),
      '#placeholder' => $this
        ->t('Privacy policy'),
    ];
    $form['all'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('All'),
      '#default_value' => $config
        ->get('texts.all'),
      '#placeholder' => $this
        ->t('Preference for all services'),
    ];
    $form['info'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Info'),
      '#default_value' => $config
        ->get('texts.info'),
      '#placeholder' => $this
        ->t('Protecting your privacy'),
    ];
    $form['disclaimer'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Disclaimer'),
      '#default_value' => $config
        ->get('texts.disclaimer'),
      '#placeholder' => $this
        ->t('By allowing these third party services, you accept their cookies and the use of tracking technologies necessary for their proper functioning.'),
    ];
    $form['allow'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Allow'),
      '#default_value' => $config
        ->get('texts.allow'),
      '#placeholder' => $this
        ->t('Allow'),
    ];
    $form['deny'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Deny'),
      '#default_value' => $config
        ->get('texts.deny'),
      '#placeholder' => $this
        ->t('Deny'),
    ];
    $form['noCookie'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('No Cookie'),
      '#default_value' => $config
        ->get('texts.noCookie'),
      '#placeholder' => $this
        ->t('This service does not use cookie.'),
    ];
    $form['useCookie'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Use Cookie'),
      '#default_value' => $config
        ->get('texts.useCookie'),
      '#placeholder' => $this
        ->t('This service can install'),
    ];
    $form['useCookieCurrent'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Use Cookie Current'),
      '#default_value' => $config
        ->get('texts.useCookieCurrent'),
      '#placeholder' => $this
        ->t('This service has installed'),
    ];
    $form['useNoCookie'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Use No Cookie'),
      '#default_value' => $config
        ->get('texts.useNoCookie'),
      '#placeholder' => $this
        ->t('This service has not installed any cookie.'),
    ];
    $form['more'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('More'),
      '#default_value' => $config
        ->get('texts.more'),
      '#placeholder' => $this
        ->t('Read more'),
    ];
    $form['source'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Source'),
      '#default_value' => $config
        ->get('texts.source'),
      '#placeholder' => $this
        ->t('View the official website'),
    ];
    $form['credit'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Credit'),
      '#default_value' => $config
        ->get('texts.credit'),
      '#placeholder' => $this
        ->t('Cookies manager by tarteaucitron.js'),
    ];
    $form['noServices'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('No Services'),
      '#default_value' => $config
        ->get('texts.noServices'),
      '#placeholder' => $this
        ->t('This website does not use any cookie requiring your consent.'),
    ];
    $form['toggleInfoBox'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Toggle Info Box'),
      '#default_value' => $config
        ->get('texts.toggleInfoBox'),
      '#placeholder' => $this
        ->t('Show/hide informations about cookie storage'),
    ];
    $form['title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Title'),
      '#default_value' => $config
        ->get('texts.title'),
      '#placeholder' => $this
        ->t('Cookies management panel'),
    ];
    $form['cookieDetail'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Cookie Detail'),
      '#default_value' => $config
        ->get('texts.cookieDetail'),
      '#placeholder' => $this
        ->t('Cookie detail for'),
    ];
    $form['ourSite'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Our Site'),
      '#default_value' => $config
        ->get('texts.ourSite'),
      '#placeholder' => $this
        ->t('on our site'),
    ];
    $form['newWindow'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('New Window'),
      '#default_value' => $config
        ->get('texts.newWindow'),
      '#placeholder' => $this
        ->t('(new window)'),
    ];
    $form['allowAll'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Allow All'),
      '#default_value' => $config
        ->get('texts.allowAll'),
      '#placeholder' => $this
        ->t('Allow all cookies'),
    ];
    $form['denyAll'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Deny All'),
      '#default_value' => $config
        ->get('texts.denyAll'),
      '#placeholder' => $this
        ->t('Deny all cookies'),
    ];
    $form['fallback'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Fallback'),
      '#default_value' => $config
        ->get('texts.fallback'),
      '#placeholder' => $this
        ->t('is disabled.'),
    ];
    $form['ads_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Ads Title'),
      '#default_value' => $config
        ->get('texts.ads.title'),
      '#placeholder' => $this
        ->t('Advertising network'),
    ];
    $form['ads_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Ads Details'),
      '#default_value' => $config
        ->get('texts.ads.details'),
      '#placeholder' => $this
        ->t('Ad networks can generate revenue by selling advertising space on the site.'),
    ];
    $form['analytic_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Analytic Title'),
      '#default_value' => $config
        ->get('texts.analytic.title'),
      '#placeholder' => $this
        ->t('Audience measurement'),
    ];
    $form['analytic_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Analytic Details'),
      '#default_value' => $config
        ->get('texts.analytic.details'),
      '#placeholder' => $this
        ->t('The audience measurement services used to generate useful statistics attendance to improve the site.'),
    ];
    $form['social_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Social Title'),
      '#default_value' => $config
        ->get('texts.social.title'),
      '#placeholder' => $this
        ->t('Social networks'),
    ];
    $form['social_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Social Details'),
      '#default_value' => $config
        ->get('texts.social.details'),
      '#placeholder' => $this
        ->t('Social networks can improve the usability of the site and help to promote it via the shares.'),
    ];
    $form['video_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Video Title'),
      '#default_value' => $config
        ->get('texts.video.title'),
      '#placeholder' => $this
        ->t('Videos'),
    ];
    $form['video_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Video Details'),
      '#default_value' => $config
        ->get('texts.video.details'),
      '#placeholder' => $this
        ->t('Video sharing services help to add rich media on the site and increase its visibility.'),
    ];
    $form['comment_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Comment Title'),
      '#default_value' => $config
        ->get('texts.comment.title'),
      '#placeholder' => $this
        ->t('Comments'),
    ];
    $form['comment_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Comment Details'),
      '#default_value' => $config
        ->get('texts.comment.details'),
      '#placeholder' => $this
        ->t('Comments managers facilitate the filing of comments and fight against spam.'),
    ];
    $form['support_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Support Title'),
      '#default_value' => $config
        ->get('texts.support.title'),
      '#placeholder' => $this
        ->t('Support'),
    ];
    $form['support_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Support Details'),
      '#default_value' => $config
        ->get('texts.support.details'),
      '#placeholder' => $this
        ->t('Support services allow you to get in touch with the site team and help to improve it.'),
    ];
    $form['api_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Api Title'),
      '#default_value' => $config
        ->get('texts.api.title'),
      '#placeholder' => $this
        ->t('APIs'),
    ];
    $form['api_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Api Details'),
      '#default_value' => $config
        ->get('texts.api.details'),
      '#placeholder' => $this
        ->t('APIs are used to load scripts: geolocation, search engines, translations, ...'),
    ];
    $form['other_title'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Other Title'),
      '#default_value' => $config
        ->get('texts.other.title'),
      '#placeholder' => $this
        ->t('Other'),
    ];
    $form['other_details'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Other Details'),
      '#default_value' => $config
        ->get('texts.other.details'),
      '#placeholder' => $this
        ->t('Services to display web content.'),
    ];
    $form['mandatoryTitle'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Mandatory title'),
      '#default_value' => $config
        ->get('texts.mandatoryTitle'),
      '#placeholder' => $this
        ->t('Mandatory cookies'),
    ];
    $form['mandatoryText'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Mandatory text'),
      '#default_value' => $config
        ->get('texts.mandatoryText'),
      '#placeholder' => $this
        ->t('This site uses cookies necessary for its proper functioning which cannot be deactivated.'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this
      ->config('tacjs.settings');
    $elements = [
      'middleBarHead',
      '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',
      'noServices',
      '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',
      'mandatoryTitle',
      'mandatoryText',
    ];
    foreach ($elements as $key) {
      if ($form_state
        ->getValue($key)) {
        $config
          ->set('texts.' . $key, $form_state
          ->getValue($key));
      }
      else {
        $config
          ->clear('texts.' . $key);
      }
    }
    $config
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EditTexts::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
EditTexts::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
EditTexts::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
EditTexts::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.