You are here

ILTResultDeleteForm.php in Opigno Instructor-led Trainings 3.x

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

File

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

namespace Drupal\opigno_ilt\Form;

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

/**
 * Provides a form for deleting a opigno_ilt_result entity.
 */
class ILTResultDeleteForm extends ContentEntityConfirmFormBase {

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

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

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return Url::fromRoute('entity.opigno_ilt_result.canonical', [
      'opigno_ilt_result' => $this->entity
        ->id(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity
      ->delete();
    $this
      ->messenger()
      ->addMessage($this
      ->t('The Instructor-Led Training Result %result has been deleted.', [
      '%result' => $this->entity
        ->label(),
    ]));
  }

}

Classes

Namesort descending Description
ILTResultDeleteForm Provides a form for deleting a opigno_ilt_result entity.