3 namespace Drupal\environment_indicator\Form;
5 use Drupal\Core\Entity\EntityConfirmFormBase;
6 use Drupal\Core\Cache\Cache;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\StringTranslation\StringTranslationTrait;
12 * Provides a deletion confirmation form for environment_indicator environment.
14 class EnvironmentIndicatorDeleteForm extends EntityConfirmFormBase {
16 use StringTranslationTrait;
21 public function getFormID() {
22 return 'environment_indicator_environment_confirm_delete';
28 public function getQuestion() {
29 return $this->t('Are you sure you want to delete the environment indicator %title?', ['%title' => $this->entity->label()]);
35 public function getCancelUrl() {
36 return new Url('aggregator.admin_overview');
42 public function getDescription() {
43 return $this->t('Deleting a environment will make disappear the indicator.');
49 public function getConfirmText() {
50 return $this->t('Delete');
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]);