You are here

public function DomainLangNegotiationConfigureForm::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 NegotiationConfigureForm::buildForm

File

src/Form/DomainLangNegotiationConfigureForm.php, line 108

Class

DomainLangNegotiationConfigureForm
Configure the selected language negotiation method for this site.

Namespace

Drupal\domain_lang\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->domainLangHandler
      ->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;
}