OrderDeleteForm.php in Ubercart 8.4
File
uc_order/src/Form/OrderDeleteForm.php
View source
<?php
namespace Drupal\uc_order\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class OrderDeleteForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to delete order @order_id?', [
'@order_id' => $this->entity
->id(),
]);
}
public function getCancelUrl() {
return new Url('view.uc_orders.admin_page');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
$this
->messenger()
->addMessage($this
->t('Order @order_id completely removed from the database.', [
'@order_id' => $this->entity
->id(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}