Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / environment_indicator / src / Form / EnvironmentIndicatorDeleteForm.php
1 <?php
2
3 namespace Drupal\environment_indicator\Form;
4
5 use Drupal\Core\Entity\EntityConfirmFormBase;
6 use Drupal\Core\Cache\Cache;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\StringTranslation\StringTranslationTrait;
9 use Drupal\Core\Url;
10
11 /**
12  * Provides a deletion confirmation form for environment_indicator environment.
13  */
14 class EnvironmentIndicatorDeleteForm extends EntityConfirmFormBase {
15
16   use StringTranslationTrait;
17
18   /**
19    * {@inheritdoc}
20    */
21   public function getFormID() {
22     return 'environment_indicator_environment_confirm_delete';
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function getQuestion() {
29     return $this->t('Are you sure you want to delete the environment indicator %title?', ['%title' => $this->entity->label()]);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function getCancelUrl() {
36     return new Url('aggregator.admin_overview');
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getDescription() {
43     return $this->t('Deleting a environment will make disappear the indicator.');
44   }
45
46   /**
47    * {@inheritdoc}
48    */
49   public function getConfirmText() {
50     return $this->t('Delete');
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   public function submitForm(array &$form, FormStateInterface $form_state) {
57     $this->entity->delete();
58     drupal_set_message($this->t('Deleted environment %name.', ['%name' => $this->entity->label()]));
59     // TODO: Figure out how to log stuff to the watchdog.
60     // watchdog('environment', 'Deleted environment %name.', ['%name' => $this->entity->label()), WATCHDOG_NOTICE);
61     $form_state['redirect'] = 'admin/config/development/environment-indicator';
62     Cache::invalidateTags(['content' => TRUE]);
63   }
64
65 }