You are here

EntityExtraFieldFormDelete.php in Entity Extra Field 8

Same filename and directory in other branches
  1. 2.0.x src/Form/EntityExtraFieldFormDelete.php

File

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

namespace Drupal\entity_extra_field\Form;

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

/**
 * Define entity extra form delete.
 */
class EntityExtraFieldFormDelete extends EntityConfirmFormBase {

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

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return $this->entity
      ->toUrl('collection');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $this->entity
      ->delete();
  }

}

Classes

Namesort descending Description
EntityExtraFieldFormDelete Define entity extra form delete.