form_field_access-1.0.0-alpha1/src/Form/FormFieldAccessDeleteForm.php
src/Form/FormFieldAccessDeleteForm.php
<?php namespace Drupal\form_field_access\Form; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; /** * Builds the form to delete Form Field Access entities. */ class FormFieldAccessDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} */ public function getQuestion() { return $this->t('Are you sure you want to delete @name field access configuration?', ['@name' => $this->entity->id()]); } /** * {@inheritdoc} */ public function getCancelUrl() { return new Url('entity.form_field_access.collection'); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->entity->delete(); $this->messenger()->addMessage( $this->t('Deleted @label Form Field Access configuration.', [ '@label' => $this->entity->label(), ] ) ); $form_state->setRedirectUrl($this->getCancelUrl()); } }