EnvironmentIndicatorDeleteForm.php in Environment Indicator 4.x
File
src/Form/EnvironmentIndicatorDeleteForm.php
View source
<?php
namespace Drupal\environment_indicator\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
class EnvironmentIndicatorDeleteForm extends EntityConfirmFormBase {
use StringTranslationTrait;
public function getFormId() {
return 'environment_indicator_environment_confirm_delete';
}
public function getQuestion() {
return $this
->t('Are you sure you want to delete the environment indicator %title?', [
'%title' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return new Url('aggregator.admin_overview');
}
public function getDescription() {
return $this
->t('Deleting a environment will make disappear the indicator.');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
$this
->messenger()
->addMessage($this
->t('Deleted environment %name.', [
'%name' => $this->entity
->label(),
]));
$form_state['redirect'] = 'admin/config/development/environment-indicator';
Cache::invalidateTags([
'content' => TRUE,
]);
}
}