You are here

public function DevelMailLoggerDeleteForm::buildForm in Devel Mail Logger 8

@inheritdoc

Overrides FormInterface::buildForm

File

src/Form/DevelMailLoggerDeleteForm.php, line 25

Class

DevelMailLoggerDeleteForm
From to delete logged mail and send test mails.

Namespace

Drupal\devel_mail_logger\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['dml_clear'] = [
    '#type' => 'fieldset',
    '#title' => t('Delete debug mails'),
    '#description' => t('This will permanently remove the debug mails from the database.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#access' => $this
      ->currentUser()
      ->hasPermission('devel_mail_logger delete test mail'),
  ];
  $form['dml_clear']['clear'] = [
    '#type' => 'submit',
    '#value' => t('Delete debug mails'),
  ];
  $url = Url::fromRoute('devel_mail_logger.send');
  $form['dml_test'] = [
    '#type' => 'fieldset',
    '#title' => t('Send test mail'),
    '#description' => t('If your mails are being logged, they will appear here after sending a test mail.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#access' => $url
      ->access(),
  ];
  $form['dml_test']['send'] = [
    '#type' => 'link',
    '#value' => t('Send test mail'),
    '#title' => t('Send test mail'),
    '#url' => $url,
    '#attributes' => [
      'class' => [
        'button',
      ],
    ],
  ];
  return $form;
}