Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
NameListFormatDeleteConfirm
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 getQuestion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCancelUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConfirmText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 submitForm
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\name\Form;
6
7use Drupal\Core\Entity\EntityConfirmFormBase;
8use Drupal\Core\Form\FormStateInterface;
9use Drupal\Core\Url;
10
11/**
12 * Builds the form to delete a name format.
13 */
14class NameListFormatDeleteConfirm extends EntityConfirmFormBase {
15
16  /**
17   * {@inheritdoc}
18   */
19  public function getQuestion() {
20    return $this->t('Are you sure you want to delete the custom list format %name?', ['%name' => $this->entity->label()]);
21  }
22
23  /**
24   * {@inheritdoc}
25   */
26  public function getCancelUrl() {
27    return new Url('name.name_list_format_list');
28  }
29
30  /**
31   * {@inheritdoc}
32   */
33  public function getConfirmText() {
34    return $this->t('Delete');
35  }
36
37  /**
38   * {@inheritdoc}
39   */
40  public function submitForm(array &$form, FormStateInterface $form_state) {
41    parent::submitForm($form, $form_state);
42    $this->entity->delete();
43    $this->messenger()->addMessage($this->t('The name list format %label has been deleted.', ['%label' => $this->entity->label()]));
44    $form_state->setRedirectUrl($this->getCancelUrl());
45  }
46
47}