You are here

EntityLegalDocumentDeleteForm.php in Entity Legal 8

File

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

/**
 * @file
 * Contains \Drupal\entity_legal\Form\EntityLegalDocumentDeleteForm.
 */
namespace Drupal\entity_legal\Form;

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

/**
 * Form builder for legal document deletion.
 */
class EntityLegalDocumentDeleteForm extends EntityConfirmFormBase {

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

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('entity_legal.list_documents');
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this
      ->t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->delete();
    drupal_set_message($this
      ->t('Legal document %label has been deleted', array(
      '%label' => $this->entity
        ->label(),
    )));
    $form_state
      ->setRedirect('entity_legal.list_documents');
  }

}

Classes

Namesort descending Description
EntityLegalDocumentDeleteForm Form builder for legal document deletion.