PriceCategoryDeleteForm.php (1186B)
1 <?php 2 3 /** 4 * @file 5 * Location: src/Form/PriceCategoryDeleteForm.php 6 * 7 * Confirmation form for deleting a price category. 8 */ 9 10 namespace Drupal\taler_turnstile\Form; 11 12 use Drupal\Core\Entity\EntityConfirmFormBase; 13 use Drupal\Core\Form\FormStateInterface; 14 use Drupal\Core\Url; 15 16 /** 17 * Builds the form to delete a price category. 18 */ 19 class PriceCategoryDeleteForm extends EntityConfirmFormBase { 20 21 /** 22 * {@inheritdoc} 23 */ 24 public function getQuestion() { 25 return $this->t('Are you sure you want to delete the price category %name?', [ 26 '%name' => $this->entity->label(), 27 ]); 28 } 29 30 /** 31 * {@inheritdoc} 32 */ 33 public function getCancelUrl() { 34 return new Url('entity.taler_turnstile_price_category.collection'); 35 } 36 37 /** 38 * {@inheritdoc} 39 */ 40 public function getConfirmText() { 41 return $this->t('Delete'); 42 } 43 44 /** 45 * {@inheritdoc} 46 */ 47 public function submitForm(array &$form, FormStateInterface $form_state) { 48 $this->entity->delete(); 49 50 $this->messenger()->addStatus($this->t('Price category %label has been deleted.', [ 51 '%label' => $this->entity->label(), 52 ])); 53 54 $form_state->setRedirectUrl($this->getCancelUrl()); 55 } 56 57 }