IdpDeleteForm.php in SAML Service Provider 3.x
File
src/Form/IdpDeleteForm.php
View source
<?php
namespace Drupal\saml_sp\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityDeleteForm;
class IdpDeleteForm extends EntityDeleteForm {
protected $idp;
public function getFormId() {
return 'saml_sp_idp_delete';
}
public function getQuestion() {
return $this
->t('Are you sure you want to delete the Identity Provider %name?', [
'%name' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return new Url('entity.idp.collection');
}
public function getDescription() {
return t('Only do this if you are sure!');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function getCancelText() {
return $this
->t('Nevermind');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
\Drupal::messenger()
->addMessage($this
->t('Identity Provider %label has been deleted.', [
'%label' => $this->entity
->label(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}