1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Contains Drupal\entity_browser\Form\EntityBrowserDeleteForm. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Drupal\entity_browser\Form; |
9
|
|
|
|
10
|
|
|
use Drupal\Core\Entity\EntityDeleteForm; |
11
|
|
|
use Drupal\Core\Url; |
12
|
|
|
use Drupal\Core\Form\FormStateInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Delete confirm form for entity browsers. |
16
|
|
|
*/ |
17
|
|
|
class EntityBrowserDeleteForm extends EntityDeleteForm { |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Gathers a confirmation question. |
21
|
|
|
* |
22
|
|
|
* @return string |
23
|
|
|
* Translated string. |
24
|
|
|
*/ |
25
|
|
|
public function getQuestion() { |
26
|
|
|
return $this->t('Are you sure you want to delete entity browser %label?', array( |
27
|
|
|
'%label' => $this->entity->label(), |
28
|
|
|
)); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Gather the confirmation text. |
33
|
|
|
* |
34
|
|
|
* @return string |
35
|
|
|
* Translated string. |
36
|
|
|
*/ |
37
|
|
|
public function getConfirmText() { |
38
|
|
|
return $this->t('Delete Entity Browser'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Gets the cancel URL. |
43
|
|
|
* |
44
|
|
|
* @return \Drupal\Core\Url |
45
|
|
|
* The URL to go to if the user cancels the deletion. |
46
|
|
|
*/ |
47
|
|
|
public function getCancelUrl() { |
48
|
|
|
return new Url('entity.entity_browser.collection'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The submit handler for the confirm form. |
53
|
|
|
* |
54
|
|
|
* @param array $form |
55
|
|
|
* An associative array containing the structure of the form. |
56
|
|
|
* @param \Drupal\Core\Form\FormStateInterface $form_state |
57
|
|
|
* An associative array containing the current state of the form. |
58
|
|
|
*/ |
59
|
|
|
public function submitForm(array &$form, FormStateInterface $form_state) { |
60
|
|
|
// Delete the entity. |
61
|
|
|
$this->entity->delete(); |
62
|
|
|
|
63
|
|
|
// Set a message that the entity was deleted. |
64
|
|
|
drupal_set_message($this->t('Entity_browser %label was deleted.', array( |
65
|
|
|
'%label' => $this->entity->label(), |
66
|
|
|
))); |
67
|
|
|
|
68
|
|
|
// Redirect the user to the list controller when complete. |
69
|
|
|
$form_state->setRedirectUrl($this->getCancelUrl()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|