function NegotiationConfigureForm::buildForm

Same name in other branches
  1. 9 core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::buildForm()
  2. 8.9.x core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::buildForm()
  3. 11.x core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::buildForm()

Overrides ConfigFormBase::buildForm

File

core/modules/language/src/Form/NegotiationConfigureForm.php, line 129

Class

NegotiationConfigureForm
Configure the selected language negotiation method for this site.

Namespace

Drupal\language\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $configurable = $this->languageTypes
        ->get('configurable');
    $form = [
        '#theme' => 'language_negotiation_configure_form',
        '#language_types_info' => $this->languageManager
            ->getDefinedLanguageTypesInfo(),
        '#language_negotiation_info' => $this->negotiator
            ->getNegotiationMethods(),
    ];
    $form['#language_types'] = [];
    foreach ($form['#language_types_info'] as $type => $info) {
        // Show locked language types only if they are configurable.
        if (empty($info['locked']) || in_array($type, $configurable)) {
            $form['#language_types'][] = $type;
        }
    }
    foreach ($form['#language_types'] as $type) {
        $this->configureFormTable($form, $type);
    }
    $form['actions'] = [
        '#type' => 'actions',
    ];
    $form['actions']['submit'] = [
        '#type' => 'submit',
        '#button_type' => 'primary',
        '#value' => $this->t('Save settings'),
    ];
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.