You are here

public function ConfigurationSendinblueForm::validateForm in SendinBlue 8

Same name and namespace in other branches
  1. 8.2 src/Form/ConfigurationSendinblueForm.php \Drupal\sendinblue\Form\ConfigurationSendinblueForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/ConfigurationSendinblueForm.php, line 116

Class

ConfigurationSendinblueForm
Parameter Form to login SendinBlue.

Namespace

Drupal\sendinblue\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $accessKey = $form_state
    ->getValue('access_key');
  if (empty($accessKey)) {
    $form_state
      ->setErrorByName('access_key', $this
      ->t('API key is invalid'));
  }
  $sendinblueMailin = $this->sendinblueManager
    ->updateSendinblueMailin($accessKey);
  $sibAccount = $sendinblueMailin
    ->getAccount();
  if (!isset($sibAccount)) {
    $form_state
      ->setErrorByName('sib_account', $this
      ->t('Unable to get account info on Sib'));
  }
}