You are here

TaxRateDeleteForm.php in Ubercart 8.4

Namespace

Drupal\uc_tax\Form

File

uc_tax/src/Form/TaxRateDeleteForm.php
View source
<?php

namespace Drupal\uc_tax\Form;

use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Deletes a tax rate.
 */
class TaxRateDeleteForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this
      ->t('Are you sure you want to delete %name?', [
      '%name' => $this->entity
        ->label(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this
      ->t('Delete tax rate');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return Url::fromRoute('entity.uc_tax_rate.collection');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->delete();
    $this
      ->messenger()
      ->addMessage($this
      ->t('Tax rate %name has been deleted.', [
      '%name' => $this->entity
        ->label(),
    ]));
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }

}

Classes

Namesort descending Description
TaxRateDeleteForm Deletes a tax rate.