BlazyDeleteFormBase.php in Blazy 8.2
File
blazy_ui/src/Form/BlazyDeleteFormBase.php
View source
<?php
namespace Drupal\blazy_ui\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
abstract class BlazyDeleteFormBase extends EntityConfirmFormBase {
protected static $niceName = 'Slick';
protected static $machineName = 'slick';
public function getQuestion() {
return $this
->t('Are you sure you want to delete the %name optionset %label?', [
'%name' => static::$niceName,
'%label' => $this->entity
->label(),
]);
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
$this
->messenger()
->addMessage($this
->t('The %name optionset %label has been deleted.', [
'%name' => static::$niceName,
'%label' => $this->entity
->label(),
]));
$this
->logger(static::$machineName)
->notice('Deleted optionset %oid (%label)', [
'%oid' => $this->entity
->id(),
'%label' => $this->entity
->label(),
]);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}