Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| NameFormatDeleteConfirm | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| getQuestion | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCancelUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getConfirmText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| submitForm | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\name\Form; |
| 6 | |
| 7 | use Drupal\Core\Entity\EntityConfirmFormBase; |
| 8 | use Drupal\Core\Form\FormStateInterface; |
| 9 | use Drupal\Core\Url; |
| 10 | |
| 11 | /** |
| 12 | * Builds the form to delete a name format. |
| 13 | */ |
| 14 | class NameFormatDeleteConfirm extends EntityConfirmFormBase { |
| 15 | |
| 16 | /** |
| 17 | * {@inheritdoc} |
| 18 | */ |
| 19 | public function getQuestion() { |
| 20 | return $this->t('Are you sure you want to delete the custom format %name?', ['%name' => $this->entity->label()]); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * {@inheritdoc} |
| 25 | */ |
| 26 | public function getCancelUrl() { |
| 27 | return new Url('name.name_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 format %label has been deleted.', ['%label' => $this->entity->label()])); |
| 44 | $form_state->setRedirectUrl($this->getCancelUrl()); |
| 45 | } |
| 46 | |
| 47 | } |