You are here

EmailDeleteForm.php in Courier 2.x

Same filename and directory in other branches
  1. 8 src/Form/EmailDeleteForm.php

File

src/Form/EmailDeleteForm.php
View source
<?php

namespace Drupal\courier\Form;

use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form for deleting an email.
 */
class EmailDeleteForm extends ContentEntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return t('Are you sure you want to delete this email?');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return $this->entity
      ->toUrl();
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $email = $this->entity;
    $email
      ->delete();
    $this
      ->messenger()
      ->addMessage($this
      ->t('Email deleted.'));
  }

}

Classes

Namesort descending Description
EmailDeleteForm Form for deleting an email.