You are here

public function EmailVerifyAdminForm::validateForm in Email Verify 8.2

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/EmailVerifyAdminForm.php, line 124
Contains \Drupal\email_verify\Form\EmailVerifyAdminForm.

Class

EmailVerifyAdminForm
Provides a form for administering Email Verify configuration.

Namespace

Drupal\email_verify\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $config = $this
    ->config('email_verify.settings');
  if ($config
    ->get('active') !== 1 && $form_state
    ->getValue('active')) {
    $this->emailVerifyManager
      ->checkHost($config
      ->get('host_name'));
    if ($this->emailVerifyManager
      ->getErrors()) {
      $form_state
        ->setErrorByName('active', $this
        ->t("Email Verify will test email domains but not mailboxes because port 25 is closed on your host's firewall"));
      \Drupal::logger('email_verify')
        ->warning('Email Verify cannot test mailboxes because port 25 is closed.');
    }
    \Drupal::logger('email_verify')
      ->notice('The Email Verify module was activated.');
  }
}