You are here

public function GoogleTranslatorUi::validateConfigurationForm in TMGMT Translator Google 8

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/GoogleTranslatorUi.php, line 45
Contains \Drupal\tmgmt_google\GoogleTranslatorUi.

Class

GoogleTranslatorUi
Google translator UI.

Namespace

Drupal\tmgmt_google

Code

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][api_key', t('The "Google API key" is not correct.'));
  }
}