XmlSitemapDeleteForm.php in XML sitemap 2.x
Same filename and directory in other branches
Namespace
Drupal\xmlsitemap\FormFile
src/Form/XmlSitemapDeleteForm.phpView source
<?php
namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
/**
* Builds the form to delete a sitemap.
*/
class XmlSitemapDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this
->t('Are you sure you want to delete %name?', [
'%name' => $this->entity
->label(),
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('xmlsitemap.admin_search_list');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this
->t('Delete');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
$this
->messenger()
->addStatus($this
->t('Sitemap %label has been deleted.', [
'%label' => $this->entity
->label(),
]));
$form_state
->setRedirect('xmlsitemap.admin_search');
}
}
Classes
Name | Description |
---|---|
XmlSitemapDeleteForm | Builds the form to delete a sitemap. |