You are here

class StepOneForm in TacJS 8

Same name and namespace in other branches
  1. 8.2 src/Form/Steps/StepOneForm.php \Drupal\tacjs\Form\Steps\StepOneForm

Class StepOneForm.

@package Drupal\tacjs\Form

Hierarchy

Expanded class hierarchy of StepOneForm

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

File

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

Namespace

Drupal\tacjs\Form\Steps
View source
class StepOneForm extends FormBase {

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

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = \Drupal::getContainer()
      ->get('config.factory')
      ->getEditable('tacjs.admin_settings_form');
    $form['tarteaucitron'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Configuration Global Tarte au Citron'),
    ];

    // Réseaux Sociaux.
    $form['tarteaucitron']['type_social_networks'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service Réseaux Sociaux'),
      '#default_value' => $config
        ->get('type_social_networks'),
      '#options' => [
        'addthis' => $this
          ->t('AddThis'),
        'addtoany_feed' => $this
          ->t('AddToAny (feed)'),
        'addtoany_share' => $this
          ->t('AddToAny (share)'),
        'ekomi' => $this
          ->t('eKomi'),
        'facebook' => $this
          ->t('Facebook'),
        'facebook_like_box' => $this
          ->t('Facebook (like box)'),
        'facebook_pixel' => $this
          ->t('Facebook Pixel'),
        'googleplus' => $this
          ->t('Google+'),
        'google_plus_badge' => $this
          ->t('Google+ (badge)'),
        'linkedin' => $this
          ->t('Linkedin'),
        'pinterest' => $this
          ->t('Pinterest'),
        'shareaholic' => $this
          ->t('Shareaholic'),
        'shareThis' => $this
          ->t('ShareThis'),
        'twitter' => $this
          ->t('Twitter'),
        'twitter_cards' => $this
          ->t('Twitter (cards)'),
        'twitter_timelines' => $this
          ->t('Twitter (timelines)'),
      ],
    ];

    // Videos.
    $form['tarteaucitron']['type_video'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service Video'),
      '#default_value' => $config
        ->get('type_video'),
      '#options' => [
        'calameo' => $this
          ->t('Calaméo'),
        'dailymotion' => $this
          ->t('Dailymotion'),
        'issuu' => $this
          ->t('Issuu'),
        'prezi' => $this
          ->t('Prezi'),
        'slideShare' => $this
          ->t('SlideShare'),
        'vimeo' => $this
          ->t('Vimeo'),
        'youtube' => $this
          ->t('Youtube'),
      ],
    ];

    // Type API.
    $form['tarteaucitron']['type_apis'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service APIs'),
      '#default_value' => $config
        ->get('type_apis'),
      '#options' => [
        'google_jsapi' => $this
          ->t('Google jsapi'),
        'google_maps' => $this
          ->t('Google Maps'),
        'google_maps_search_query' => $this
          ->t('Google Maps (search query)'),
        'google_tag_manager' => $this
          ->t('Google Tag Manager'),
        'reCAPTCHA' => $this
          ->t('reCAPTCHA'),
        'timeline_js' => $this
          ->t('Timeline JS'),
        'typekit_adobe' => $this
          ->t('Typekit (adobe)'),
      ],
    ];

    // Comment.
    $form['tarteaucitron']['type_commentaire'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service Commentaire'),
      '#default_value' => $config
        ->get('type_commentaire'),
      '#options' => [
        'DisqusInstaller' => $this
          ->t('Disqus'),
        'facebook_commentaire' => $this
          ->t('Facebook (comment)'),
      ],
    ];

    // Mesure d'audience.
    $form['tarteaucitron']['type_mesure_audience'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service Mesure d audiance'),
      '#default_value' => $config
        ->get('type_mesure_audience'),
      '#options' => [
        'alexa' => $this
          ->t('Alexa'),
        'clicky' => $this
          ->t('Clicky'),
        'crazyegg' => $this
          ->t('Crazy Egg'),
        'etracker' => $this
          ->t('eTracker'),
        'ferank' => $this
          ->t('FERank'),
        'getplus' => $this
          ->t('Get+'),
        'gajs' => $this
          ->t('Google Analytics (ga.js)'),
        'gtag' => $this
          ->t('Google Analytics (gtag.js)'),
        'multiplegtag' => $this
          ->t('Google Analytics (gtag.js) [for multiple UA]'),
        'analytics' => $this
          ->t('Google Analytics (universal)'),
        'koban' => $this
          ->t('Koban'),
        'mautic' => $this
          ->t('Mautic'),
        'microsoftcampaignanalytics' => $this
          ->t('Microsoft Campaign Analytics'),
        'statcounter' => $this
          ->t('StatCounter'),
        'visualrevenue' => $this
          ->t('VisualRevenue'),
        'webmecanik' => $this
          ->t('Webmecanik'),
        'wysistat' => $this
          ->t('Wysistat'),
        'xiti' => $this
          ->t('Xiti'),
      ],
    ];

    // Regie Publicitaire.
    $form['tarteaucitron']['type_regie_publicitaire'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service Régie publicitaire'),
      '#default_value' => $config
        ->get('type_regie_publicitaire'),
      '#options' => [
        'aduptech_ads' => $this
          ->t('Ad Up Technology (ads)'),
        'aduptech_conversion' => $this
          ->t('Ad Up Technology (conversion)'),
        'aduptech_retargeting' => $this
          ->t('Ad Up Technology (retargeting)'),
        'amazon' => $this
          ->t('Amazon'),
        'clicmanager' => $this
          ->t('Clicmanager'),
        'criteo' => $this
          ->t('Criteo'),
        'datingaffiliation' => $this
          ->t('Dating Affiliation'),
        'datingaffiliationpopup' => $this
          ->t('Dating Affiliation (popup)'),
        'ferankpub' => $this
          ->t('FERank (pub)'),
        'adsense' => $this
          ->t('Google Adsense'),
        'adsensesearchform' => $this
          ->t('Google Adsense Search (form)'),
        'adsensesearchresult' => $this
          ->t('Google Adsense Search (result)'),
        'googleadwordsconversion' => $this
          ->t('Google Adwords (conversion)'),
        'googleadwordsremarketing' => $this
          ->t('Google Adwords (remarketing)'),
        'googlepartners' => $this
          ->t('Google Partners Badge'),
        'prelinker' => $this
          ->t('Prelinker'),
        'pubdirecte' => $this
          ->t('Pubdirecte'),
        'shareasale' => $this
          ->t('ShareASale'),
        'twenga' => $this
          ->t('Twenga'),
        'vshop' => $this
          ->t('vShop'),
      ],
    ];

    // Support.
    $form['tarteaucitron']['type_support'] = [
      '#type' => 'select',
      '#multiple' => TRUE,
      '#title' => $this
        ->t('Sélectionner le Service support'),
      '#default_value' => $config
        ->get('type_support'),
      '#options' => [
        'purechat' => $this
          ->t('PureChat'),
        'uservoice' => $this
          ->t('UserVoice'),
        'zopim' => $this
          ->t('Zopim'),
      ],
    ];

    // Actions.
    $form['actions']['submit']['#value'] = $this
      ->t('Next');
    $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.admin_settings_form');

    // Get all values and save it in save variable.
    $formvalues = $form_state
      ->getValues();
    $formvalues = \Drupal::service('tacjs.settings')
      ->serializeValuesForm($formvalues);
    $config
      ->set('donnes_step_one', $formvalues);

    // Get values fields.
    $type_social_networks = $form_state
      ->getValue('type_social_networks');
    $type_video = $form_state
      ->getValue('type_video');
    $type_apis = $form_state
      ->getValue('type_apis');
    $type_commentaire = $form_state
      ->getValue('type_commentaire');
    $type_mesure_audience = $form_state
      ->getValue('type_mesure_audience');
    $type_regie_publicitaire = $form_state
      ->getValue('type_regie_publicitaire');
    $type_support = $form_state
      ->getValue('type_support');

    // Save values.
    $config
      ->set('type_social_networks', $type_social_networks);
    $config
      ->set('type_video', $type_video);
    $config
      ->set('type_apis', $type_apis);
    $config
      ->set('type_commentaire', $type_commentaire);
    $config
      ->set('type_mesure_audience', $type_mesure_audience);
    $config
      ->set('type_regie_publicitaire', $type_regie_publicitaire);
    $config
      ->set('type_support', $type_support);
    $config
      ->save();

    // Redirect to step two.
    $form_state
      ->setRedirect('tacjs.step_two');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 87
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.
StepOneForm::buildForm public function Form constructor. Overrides FormInterface::buildForm
StepOneForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
StepOneForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm
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.