function mailgun_test_settings_form_validate in Mailgun 8
Overridden validate for test purposes.
1 string reference to 'mailgun_test_settings_form_validate'
- mailgun_test_form_mailgun_admin_settings_form_alter in tests/
modules/ mailgun_test/ mailgun_test.module - Implements hook_form_FORM_ID_alter().
File
- tests/
modules/ mailgun_test/ mailgun_test.module, line 22 - Mailgun test module.
Code
function mailgun_test_settings_form_validate($form, FormStateInterface $form_state) {
/** @var \Drupal\mailgun\MailgunHandlerInterface $mailgun_handler */
$mailgun_handler = \Drupal::service('mailgun.mail_handler');
if ($form_state
->getValue('api_key') === 'key-1234567890workingabcdefghijklmno') {
// Do nothing. It's just to emulate correct API key.
}
elseif ($mailgun_handler
->validateMailgunApiKey($form_state
->getValue('api_key')) === FALSE) {
$form_state
->setErrorByName('api_key', "Couldn't connect to the Mailgun API. Please check your API settings.");
}
}