You are here

public function NegotiationConfigureForm::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::buildForm()

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 ConfigFormBase::buildForm

File

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

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;
}