You are here

public function LingotekSettingsTabConfigurationForm::buildForm in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  2. 4.0.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  3. 3.0.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  4. 3.1.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  5. 3.2.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  6. 3.3.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  7. 3.4.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  8. 3.5.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  9. 3.6.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  10. 3.7.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::buildForm()
  11. 3.8.x src/Form/LingotekSettingsTabConfigurationForm.php \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm::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

src/Form/LingotekSettingsTabConfigurationForm.php, line 107
Contains \Drupal\lingotek\Form\LingotekSettingsTabConfigurationForm.

Class

LingotekSettingsTabConfigurationForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $profile_options = $this->lingotekConfig
    ->getProfileOptions();
  $header = array(
    'enabled' => $this
      ->t('Enable'),
    'type' => $this
      ->t('Configuration Type'),
    'profile' => $this
      ->t('Translation Profile'),
  );
  $table = array(
    '#type' => 'table',
    '#header' => $header,
    '#empty' => $this
      ->t('No Entries'),
  );
  foreach ($this->mappers as $mapper) {

    // We don't want to show config objects, where we only have one instance.
    // Just show config entities.
    if ($mapper instanceof ConfigEntityMapper) {
      $enabled = $this->translationService
        ->isEnabled($mapper
        ->getPluginId());
      $row = array();
      $row['enabled'] = array(
        '#type' => 'checkbox',
        '#default_value' => $enabled,
      );
      $row['type'] = array(
        '#markup' => $mapper
          ->getTypeLabel(),
      );
      $row['profile'] = [
        '#type' => 'select',
        '#options' => $this->lingotekConfig
          ->getProfileOptions(),
        '#default_value' => $this->lingotekConfig
          ->getConfigEntityDefaultProfileId($mapper
          ->getPluginId()),
      ];
      $table[$mapper
        ->getPluginId()] = $row;
    }
  }
  ksort($table);
  $form['config'] = array(
    '#type' => 'details',
    '#title' => 'Translate Configuration Types',
  );
  $form['config']['table'] = $table;
  $form['config']['actions']['#type'] = 'actions';
  $form['config']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#button_type' => 'primary',
  );
  return $form;
}