You are here

public function LingotekSettingsDefaultsForm::init in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  2. 4.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  3. 3.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  4. 3.1.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  5. 3.2.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  6. 3.3.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  7. 3.4.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  8. 3.5.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  9. 3.6.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  10. 3.7.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
  11. 3.8.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
2 calls to LingotekSettingsDefaultsForm::init()
LingotekSettingsDefaultsForm::buildForm in src/Form/LingotekSettingsDefaultsForm.php
Form constructor.
LingotekSettingsEditDefaultsForm::init in src/Form/LingotekSettingsEditDefaultsForm.php
1 method overrides LingotekSettingsDefaultsForm::init()
LingotekSettingsEditDefaultsForm::init in src/Form/LingotekSettingsEditDefaultsForm.php

File

src/Form/LingotekSettingsDefaultsForm.php, line 21
Contains \Drupal\lingotek\Form\LingotekSettingsProjectVaultForm.

Class

LingotekSettingsDefaultsForm
Configure text display settings for this page.

Namespace

Drupal\lingotek\Form

Code

public function init() {
  $this->defaults = $this->lingotek
    ->getDefaults();
  $this->resources = $this->lingotek
    ->getResources();

  // Make visible only those options that have more than one choice
  if (count($this->resources['project']) > 1) {
    $this->defaults_labels['project'] = t('Default Project');
  }
  elseif (count($this->resources['project']) == 1) {
    $this->lingotek
      ->set('default.project', current(array_keys($this->resources['project'])));
  }
  if (count($this->resources['vault']) > 1) {
    $this->defaults_labels['vault'] = t('Default Vault');
  }
  elseif (count($this->resources['vault']) == 1) {
    $this->lingotek
      ->set('default.vault', current(array_keys($this->resources['vault'])));
  }

  // Set workflow to machine translation every time regardless if there's more than one choice
  $machine_translation = array_search('Machine Translation', $this->resources['workflow']);
  if ($machine_translation) {
    $this->lingotek
      ->set('default.workflow', $machine_translation);
  }
}