You are here

public function DomainLangNegotiationSessionForm::buildForm in Domain Lang 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides NegotiationSessionForm::buildForm

File

src/Form/DomainLangNegotiationSessionForm.php, line 64

Class

DomainLangNegotiationSessionForm
Configure the session language negotiation method for this site.

Namespace

Drupal\domain_lang\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config($this->languageNegotiationConfig);
  $form = parent::buildForm($form, $form_state);

  // Fill with initial values on first page visit.
  if (!$config
    ->get('session.parameter')) {
    $config
      ->set('session.parameter', $this
      ->config('language.negotiation')
      ->get('session.parameter'));
  }
  if (isset($form['language_negotiation_session_param'])) {
    $form['language_negotiation_session_param']['#default_value'] = $config
      ->get('session.parameter');
  }
  return $form;
}