You are here

AuthorPaneDeleteForm.php in Author Pane 8.3

File

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

/**
 * @file
 * Contains \Drupal\author_pane\Form\AuthorPaneDeleteForm.
 */
namespace Drupal\author_pane\Form;

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

/**
 * Form that handles the removal of Author Pane entities.
 */
class AuthorPaneDeleteForm extends EntityConfirmFormBase {

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

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

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('entity.author_pane.list');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    // Delete the entity.
    $this->entity
      ->delete();

    // Set a message that the entity was deleted.
    drupal_set_message($this
      ->t('Robot %label was deleted.', array(
      '%label' => $this->entity
        ->label(),
    )));

    // Redirect the user to the list controller when complete.
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }

}

Classes

Namesort descending Description
AuthorPaneDeleteForm Form that handles the removal of Author Pane entities.