MaillogClearConfirmForm.php in Maillog / Mail Developer 8
File
src/Form/MaillogClearConfirmForm.php
View source
<?php
namespace Drupal\maillog\Form;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
class MaillogClearConfirmForm extends ConfirmFormBase {
public function getFormId() {
return 'maillog_clear_log';
}
public function getDescription() {
return $this
->t('All maillog database entries will be deleted. This action cannot be undone.');
}
public function getQuestion() {
return $this
->t('Are you sure you want to clear all the maillog entries?');
}
public function getCancelUrl() {
return new Url('maillog.settings');
}
public function getConfirmText() {
return $this
->t('Clear');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
Database::getConnection('default')
->truncate('maillog')
->execute();
$this
->messenger()
->addStatus($this
->t("All maillog entries have been deleted."));
$form_state
->setRedirect('maillog.settings');
}
}