public function SmartlingTranslatorUi::validateConfigurationForm in TMGMT Translator Smartling 8
Same name and namespace in other branches
- 8.4 src/SmartlingTranslatorUi.php \Drupal\tmgmt_smartling\SmartlingTranslatorUi::validateConfigurationForm()
- 8.2 src/SmartlingTranslatorUi.php \Drupal\tmgmt_smartling\SmartlingTranslatorUi::validateConfigurationForm()
- 8.3 src/SmartlingTranslatorUi.php \Drupal\tmgmt_smartling\SmartlingTranslatorUi::validateConfigurationForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides TranslatorPluginUiBase::validateConfigurationForm
File
- src/
SmartlingTranslatorUi.php, line 221 - Contains \Drupal\tmgmt_smartling\SmartlingTranslatorUi.
Class
- SmartlingTranslatorUi
- Smartling translator UI.
Namespace
Drupal\tmgmt_smartlingCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
/** @var \Drupal\tmgmt\TranslatorInterface $translator */
$translator = $form_state
->getFormObject()
->getEntity();
$supported_remote_languages = $translator
->getPlugin()
->getSupportedRemoteLanguages($translator);
if (empty($supported_remote_languages)) {
$form_state
->setErrorByName('settings][project_id', t('The "Project ID", the "Client key" or both are not correct.'));
$form_state
->setErrorByName('settings][key', t('The "Project ID", the "Client key" or both are not correct.'));
}
if ($translator
->getSetting('enable_basic_auth')) {
$auth_settings = $translator
->getSetting('basic_auth');
if (empty($auth_settings['login']) || empty($auth_settings['password'])) {
$form_state
->setErrorByName('settings][basic_auth', t('Please fill in both login and password (HTTP basic authentication credentials).'));
}
}
}