Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / migrate_tools / src / Form / MigrationDeleteForm.php
1 <?php
2
3 namespace Drupal\migrate_tools\Form;
4
5 use Drupal\Core\Entity\EntityConfirmFormBase;
6 use Drupal\Core\Url;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * Provides the delete form for our Migration entity.
11  *
12  * @package Drupal\migrate_tools\Form
13  *
14  * @ingroup migrate_tools
15  */
16 class MigrationDeleteForm extends EntityConfirmFormBase {
17
18   /**
19    * Gathers a confirmation question.
20    *
21    * @return string
22    *   Translated string.
23    */
24   public function getQuestion() {
25     return $this->t('Are you sure you want to delete migration %label?', [
26       '%label' => $this->entity->label(),
27     ]);
28   }
29
30   /**
31    * Gather the confirmation text.
32    *
33    * @return string
34    *   Translated string.
35    */
36   public function getConfirmText() {
37     return $this->t('Delete Migration');
38   }
39
40   /**
41    * Gets the cancel URL.
42    *
43    * @return \Drupal\Core\Url
44    *   The URL to go to if the user cancels the deletion.
45    */
46   public function getCancelUrl() {
47     return new Url('entity.migration_group.list');
48   }
49
50   /**
51    * The submit handler for the confirm form.
52    *
53    * @param array $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.
57    */
58   public function submitForm(array &$form, FormStateInterface $form_state) {
59     // Delete the entity.
60     $this->entity->delete();
61
62     // Set a message that the entity was deleted.
63     drupal_set_message(t('Migration %label was deleted.', [
64       '%label' => $this->entity->label(),
65     ]));
66
67     // Redirect the user to the list controller when complete.
68     $form_state->setRedirectUrl($this->getCancelUrl());
69   }
70
71 }