You are here

ResponseHeaderDeleteForm.php in HTTP Response Headers 8.2

Same filename and directory in other branches
  1. 2.0.x src/Form/ResponseHeaderDeleteForm.php

File

src/Form/ResponseHeaderDeleteForm.php
View source
<?php

namespace Drupal\http_response_headers\Form;

use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;

/**
 * Builds the form to delete an Response Header.
 */
class ResponseHeaderDeleteForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this
      ->t('Are you sure you want to delete the %name header?', array(
      '%name' => $this->entity
        ->label(),
    ));
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('entity.response_header.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('The header %label has been deleted.', array(
      '%label' => $this->entity
        ->label(),
    )));
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }

}

Classes

Namesort descending Description
ResponseHeaderDeleteForm Builds the form to delete an Response Header.