-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdvertiserDeleteForm.php
56 lines (47 loc) · 1.27 KB
/
AdvertiserDeleteForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Drupal\drupal10_custom_module\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Provides a form for deleting a advertiser entity.
*
* @ingroup advertiser
*/
class AdvertiserDeleteForm extends ContentEntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete entity %name?', ['%name' => $this->entity->label()]);
}
/**
* {@inheritdoc}
*
* If the delete command is canceled, return to the contact list.
*/
public function getCancelUrl() {
return new Url('entity.advertiser.collection');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this->t('Delete');
}
/**
* {@inheritdoc}
*
* Delete the entity and log the event. logger() replaces the watchdog.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->getEntity();
$entity->delete();
$this->logger('content_entity_example')->notice('@type: deleted %title.',
[
'@type' => $this->entity->bundle(),
'%title' => $this->entity->label(),
]);
$form_state->setRedirect('entity.advertiser.collection');
}
}