LoginDestinationDeleteRuleForm.php in Login Destination 8.2
File
src/Form/LoginDestinationDeleteRuleForm.php
View source
<?php
namespace Drupal\login_destination\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class LoginDestinationDeleteRuleForm extends EntityConfirmFormBase {
public function getQuestion() {
$login_destination = $this->entity;
return $this
->t('Are you sure you want to delete the login destination "@destination"?', [
'@destination' => $login_destination
->getLabel(),
]);
}
public function getCancelUrl() {
return new Url('login_destination.list');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$login_destination = $this->entity;
$login_destination
->delete();
$this
->messenger()
->addMessage($this
->t('The login destination %destination has been deleted.', [
'%destination' => $login_destination
->getLabel(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}