Version 1
[yaffs-website] / vendor / drupal / console / templates / module / src / Form / entity-delete.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\Form\{{ entity_class }}DeleteForm.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\Form;
9 {% endblock %}
10
11 {% block use_class %}
12 use Drupal\Core\Entity\EntityConfirmFormBase;
13 use Drupal\Core\Form\FormStateInterface;
14 use Drupal\Core\Url;
15 {% endblock %}
16
17 {% block class_declaration %}
18 /**
19  * Builds the form to delete {{ label }} entities.
20  */
21 class {{ entity_class }}DeleteForm extends EntityConfirmFormBase {% endblock %}
22 {% block class_methods %}
23   /**
24    * {@inheritdoc}
25    */
26   public function getQuestion() {
27     return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function getCancelUrl() {
34     return new Url('entity.{{ entity_name }}.collection');
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function getConfirmText() {
41     return $this->t('Delete');
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function submitForm(array &$form, FormStateInterface $form_state) {
48     $this->entity->delete();
49
50     drupal_set_message(
51       $this->t('content @type: deleted @label.',
52         [
53           '@type' => $this->entity->bundle(),
54           '@label' => $this->entity->label(),
55         ]
56         )
57     );
58
59     $form_state->setRedirectUrl($this->getCancelUrl());
60   }
61 {% endblock %}