Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
AuthorizationProfileDeleteForm | |
100.00% |
12 / 12 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
getFormId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 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% |
8 / 8 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\authorization\Form; |
6 | |
7 | use Drupal\Core\Entity\EntityConfirmFormBase; |
8 | use Drupal\Core\Form\FormStateInterface; |
9 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
10 | use Drupal\Core\Url; |
11 | |
12 | /** |
13 | * Builds the form to delete Authorization profile entities. |
14 | */ |
15 | class AuthorizationProfileDeleteForm extends EntityConfirmFormBase { |
16 | |
17 | /** |
18 | * {@inheritdoc} |
19 | */ |
20 | public function getFormId(): string { |
21 | return 'authorization_profile_delete_form'; |
22 | } |
23 | |
24 | /** |
25 | * {@inheritdoc} |
26 | */ |
27 | public function getQuestion(): TranslatableMarkup { |
28 | return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); |
29 | } |
30 | |
31 | /** |
32 | * {@inheritdoc} |
33 | */ |
34 | public function getCancelUrl(): Url { |
35 | return new Url('entity.authorization_profile.edit_form', ['authorization_profile' => $this->entity->id()]); |
36 | } |
37 | |
38 | /** |
39 | * {@inheritdoc} |
40 | */ |
41 | public function getConfirmText(): TranslatableMarkup { |
42 | return $this->t('Delete'); |
43 | } |
44 | |
45 | /** |
46 | * {@inheritdoc} |
47 | */ |
48 | public function submitForm(array &$form, FormStateInterface $form_state): void { |
49 | $this->entity->delete(); |
50 | |
51 | $this->messenger()->addStatus($this->t('content @type: deleted @label.', |
52 | [ |
53 | '@type' => $this->entity->bundle(), |
54 | '@label' => $this->entity->label(), |
55 | ] |
56 | )); |
57 | |
58 | $form_state->setRedirect('entity.authorization_profile.collection'); |
59 | } |
60 | |
61 | } |