3 namespace Drupal\migrate_tools\Form;
5 use Drupal\Core\Entity\EntityConfirmFormBase;
7 use Drupal\Core\Form\FormStateInterface;
10 * Provides the delete form for our Migration Group entity.
12 * @package Drupal\migrate_tools\Form
14 * @ingroup migrate_tools
16 class MigrationGroupDeleteForm extends EntityConfirmFormBase {
19 * Gathers a confirmation question.
24 public function getQuestion() {
25 return $this->t('Are you sure you want to delete migration group %label?', [
26 '%label' => $this->entity->label(),
31 * Gather the confirmation text.
36 public function getConfirmText() {
37 return $this->t('Delete Migration Group');
41 * Gets the cancel URL.
43 * @return \Drupal\Core\Url
44 * The URL to go to if the user cancels the deletion.
46 public function getCancelUrl() {
47 return new Url('entity.migration_group.list');
51 * The submit handler for the confirm form.
54 * An associative array containing the structure of the form.
55 * @param \Drupal\Core\Form\FormStateInterface $form_state
56 * An associative array containing the current state of the form.
58 public function submitForm(array &$form, FormStateInterface $form_state) {
60 $this->entity->delete();
62 // Set a message that the entity was deleted.
63 drupal_set_message(t('Migration group %label was deleted.', [
64 '%label' => $this->entity->label(),
67 // Redirect the user to the list controller when complete.
68 $form_state->setRedirectUrl($this->getCancelUrl());