public function LingotekSettingsDefaultsForm::init in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8 src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 8.2 src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 4.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.0.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.1.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.2.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.3.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.5.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.6.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.7.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
- 3.8.x src/Form/LingotekSettingsDefaultsForm.php \Drupal\lingotek\Form\LingotekSettingsDefaultsForm::init()
1 call to LingotekSettingsDefaultsForm::init()
- LingotekSettingsDefaultsForm::buildForm in src/
Form/ LingotekSettingsDefaultsForm.php - Form constructor.
1 method overrides LingotekSettingsDefaultsForm::init()
File
- src/
Form/ LingotekSettingsDefaultsForm.php, line 15
Class
- LingotekSettingsDefaultsForm
- Configure text display settings for this page.
Namespace
Drupal\lingotek\FormCode
public function init() {
$config = \Drupal::configFactory()
->getEditable('lingotek.settings');
$this->defaults = $config
->get('default');
$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) {
$config
->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) {
$config
->set('default.vault', current(array_keys($this->resources['vault'])));
}
if (count($this->resources['workflow']) > 1) {
$this->defaults_labels['workflow'] = t('Default Workflow');
}
elseif (count($this->resources['workflow']) == 1) {
$config
->set('default.workflow', current(array_keys($this->resources['workflow'])));
}
if (count($this->resources['filter']) > 1) {
$this->defaults_labels['filter'] = t('Default Filter');
$this->defaults_labels['subfilter'] = t('Default Subfilter');
}
else {
$config
->set('default.filter', 'drupal_default');
$config
->set('default.subfilter', 'drupal_default');
}
// 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) {
$config
->set('default.workflow', $machine_translation);
}
$config
->save();
}