GoogleImageSitemapDeleteForm.php in Google Image Sitemap 2.0.x
File
src/Form/GoogleImageSitemapDeleteForm.php
View source
<?php
namespace Drupal\google_image_sitemap\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class GoogleImageSitemapDeleteForm extends ConfirmFormBase {
protected $id;
public function getFormId() {
return 'google_image_sitemap_delete_form';
}
public function getQuestion() {
return $this
->t('Do you want to delete %id?', [
'%id' => $this->id,
]);
}
public function getCancelUrl() {
return new Url('my_module.myroute');
}
public function getDescription() {
return $this
->t('Only do this if you are sure!');
}
public function getConfirmText() {
return $this
->t('Delete it!');
}
public function getCancelText() {
return $this
->t('Nevermind');
}
public function buildForm(array $form, FormStateInterface $form_state, $id = NULL) {
echo $id;
die('here');
$this->id = $id;
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
mymodule_delete($this->id);
}
}