You are here

PollItemsDeleteForm.php in Poll 8

Namespace

Drupal\poll\Form

File

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

namespace Drupal\poll\Form;

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

/**
 * Provides a deletion confirmation form for items that belong to a feed.
 */
class PollItemsDeleteForm extends ContentEntityConfirmFormBase {

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

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

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

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->deleteItems();
    $form_state
      ->setRedirect('poll.poll_list');
  }

}

Classes

Namesort descending Description
PollItemsDeleteForm Provides a deletion confirmation form for items that belong to a feed.