alert_types-8.x-1.x-dev/src/Form/AlertTypeDeleteForm.php
src/Form/AlertTypeDeleteForm.php
<?php namespace Drupal\alert_types\Form; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** * Builds the form to delete Alert type entities. */ class AlertTypeDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ public function getQuestion() { return $this->t('Are you sure you want to delete the alert type %name?', ['%name' => $this->entity->label()]); } /** * {@inheritdoc} */ public function getCancelUrl() { return new Url('entity.alert_type.collection'); } /** * {@inheritdoc} */ public function getConfirmText() { return $this->t('Delete'); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->delete(); \Drupal::messenger()->addStatus( $this->t('Alert type deleted: @label.', [ '@label' => $this->entity->label(), ] ) ); $form_state->setRedirectUrl($this->getCancelUrl()); } }