class NegotiationSessionForm

Configure the session language negotiation method for this site.

Hierarchy

Expanded class hierarchy of NegotiationSessionForm

1 string reference to 'NegotiationSessionForm'
language.routing.yml in drupal/core/modules/language/language.routing.yml
drupal/core/modules/language/language.routing.yml

File

drupal/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php, line 15
Contains \Drupal\language\Form\NegotiationSessionForm.

Namespace

Drupal\language\Form
View source
class NegotiationSessionForm extends SystemConfigFormBase {

  /**
   * Implements \Drupal\Core\Form\FormInterface::getFormID().
   */
  public function getFormID() {
    return 'language_negotiation_configure_session_form';
  }

  /**
   * Implements \Drupal\Core\Form\FormInterface::buildForm().
   */
  public function buildForm(array $form, array &$form_state) {
    $config = $this->configFactory
      ->get('language.negotiation');
    $form['language_negotiation_session_param'] = array(
      '#title' => t('Request/session parameter'),
      '#type' => 'textfield',
      '#default_value' => $config
        ->get('session.parameter'),
      '#description' => t('Name of the request/session parameter used to determine the desired language.'),
    );
    $form_state['redirect'] = 'admin/config/regional/language/detection';
    return parent::buildForm($form, $form_state);
  }

  /**
   * Implements \Drupal\Core\Form\FormInterface::submitForm().
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->configFactory
      ->get('language.settings')
      ->set('session.parameter', $form_state['values']['language_negotiation_session_param'])
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members