ILTResultDeleteForm.php in Opigno Instructor-led Trainings 3.x
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;
class ILTResultDeleteForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to delete the %result Instructor-Led Training Result?', [
'%result' => $this->entity
->label(),
]);
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function getCancelUrl() {
return Url::fromRoute('entity.opigno_ilt_result.canonical', [
'opigno_ilt_result' => $this->entity
->id(),
]);
}
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(),
]));
}
}