Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthorizationProfileDeleteForm
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 getFormId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 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%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\authorization\Form;
6
7use Drupal\Core\Entity\EntityConfirmFormBase;
8use Drupal\Core\Form\FormStateInterface;
9use Drupal\Core\StringTranslation\TranslatableMarkup;
10use Drupal\Core\Url;
11
12/**
13 * Builds the form to delete Authorization profile entities.
14 */
15class 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}