You are here

MiconDeleteForm.php in Micon 2.x

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

Namespace

Drupal\micon\Form

File

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

namespace Drupal\micon\Form;

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

/**
 * Builds the form to delete Micon entities.
 */
class MiconDeleteForm extends EntityConfirmFormBase {

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

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

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

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->delete();
    $this
      ->messenger()
      ->addStatus($this
      ->t('Micon package @label has been removed.', [
      '@label' => $this->entity
        ->label(),
    ]));
    drupal_flush_all_caches();
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }

}

Classes

Namesort descending Description
MiconDeleteForm Builds the form to delete Micon entities.