comparison modules/contrib/migrate_tools/src/Form/MigrationGroupDeleteForm.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 * Class MigrationGroupDeleteForm.
11 *
12 * @package Drupal\migrate_tools\Form
13 *
14 * @ingroup migrate_tools
15 */
16 class MigrationGroupDeleteForm 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 group %label?', array(
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 Group');
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 group %label was deleted.', array(
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 }