FillPdfFormDeleteForm.php in FillPDF 8.4
File
src/Form/FillPdfFormDeleteForm.php
View source
<?php
namespace Drupal\fillpdf\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;
class FillPdfFormDeleteForm extends FillPdfFormConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to delete %name?', [
'%name' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return $this
->getEntity()
->toUrl('canonical');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$fillpdf_form = $this
->getEntity();
$file = File::load($fillpdf_form
->get('file')
->first()->target_id);
$fillpdf_form
->delete();
$this
->messenger()
->addStatus($this
->t('FillPDF form deleted.'));
$form_state
->setRedirect('fillpdf.forms_admin');
}
}