linkit_custom_link-1.0.0-alpha1/src/Form/LinkitCustomLinkDeleteForm.php
src/Form/LinkitCustomLinkDeleteForm.php
<?php namespace Drupal\linkit_custom_link\Form; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Url; use Drupal\Core\Form\FormStateInterface; /** * Builds the form to delete a link. */ class LinkitCustomLinkDeleteForm 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('entity.linkit_custom_link.collection'); } /** * {@inheritdoc} */ public function getConfirmText() { return $this->t('Delete'); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->delete(); $this->messenger()->addMessage($this->t('Entity %label has been deleted.', ['%label' => $this->entity->label()])); $form_state->setRedirectUrl($this->getCancelUrl()); } }