public function PostmarkSettingsForm::submitForm in Postmark 8
Form submission 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 ConfigFormBase::submitForm
File
- src/
Form/ PostmarkSettingsForm.php, line 126
Class
- PostmarkSettingsForm
- Configure Postmark settings.
Namespace
Drupal\postmark\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('postmark.settings');
$config
->set('postmark_api_key', $form_state
->getValue('postmark_api_key'))
->set('postmark_sender_signature', $form_state
->getValue('postmark_sender_signature'))
->set('postmark_debug_mode', $form_state
->getValue('postmark_debug_mode'))
->set('postmark_debug_email', $form_state
->getValue('postmark_debug_email'))
->set('postmark_debug_no_send', $form_state
->getValue('postmark_debug_no_send'))
->save();
// If an address is submitted, send a test email message.
$test_address = $form_state
->getValue('test_address');
if ($test_address) {
$message = $this
->t('A test e-mail has been sent to @mail. You may want to check the logs for any error messages.', [
'@mail' => $test_address,
]);
$this
->messenger()
->addWarning($message);
$postmark_message = [
'from' => $form_state
->getValue('postmark_sender_signature'),
'to' => $test_address,
'subject' => $this
->t('Test message from Postmark'),
'text' => $this
->t('Just testing.'),
];
$this->postmarkHandler
->sendMail($postmark_message);
}
parent::submitForm($form, $form_state);
}