TripalBlastDatabaseDeleteForm.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * This is the the form to handle BLAST database deletion.
  5. */
  6. namespace Drupal\tripal_blast\Form;
  7. use Drupal\Core\Entity\EntityConfirmFormBase;
  8. use Drupal\Core\Url;
  9. use Drupal\Core\Form\FormStateInterface;
  10. /**
  11. * Construct for to delete BLAST database.
  12. */
  13. class TripalBlastDatabaseDeleteForm extends EntityConfirmFormBase {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function getQuestion() {
  18. return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->getName()]);
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getCancelUrl() {
  24. return new Url('entity.tripal_blast.blast_database');
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function getConfirmText() {
  30. return $this->t('Delete');
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function submitForm(array &$form, FormStateInterface $form_state) {
  36. $this->entity->delete();
  37. $this->messenger()->addMessage($this->t('BLAST database %name has been deleted.', ['%name' => $this->entity->getName()]));
  38. $form_state->setRedirectUrl($this->getCancelUrl());
  39. }
  40. }