You are here

FlagListItemDeleteForm.php in Flag Lists 4.0.x

Same filename and directory in other branches
  1. 8 src/Form/FlagListItemDeleteForm.php

File

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

namespace Drupal\flag_lists\Form;

use Drupal\Core\Entity\ContentEntityDeleteForm;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a form for deleting Flag List Item entities.
 *
 * @ingroup flag_lists
 */
class FlagListItemDeleteForm extends ContentEntityDeleteForm {

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this
      ->t('Please note that this is only to delete erranious Flag List Items in the case upgrade problems. In the normal case you would like to "unflag" the Flag List Item instead of "delete" it. Are you still really sure you want to delete it?');
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $entity = $this
      ->getEntity();
    $form = parent::buildForm($form, $form_state);
    return $form;
  }

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

    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $this
      ->getEntity();
    $entity
      ->delete();
    $message = $this
      ->getDeletionMessage();
    $this
      ->messenger()
      ->addStatus($message);
    $this
      ->logDeletionMessage();
  }

}

Classes

Namesort descending Description
FlagListItemDeleteForm Provides a form for deleting Flag List Item entities.