ParallaxElementDeleteForm.php in Parallax Background 8
File
src/Form/ParallaxElementDeleteForm.php
View source
<?php
namespace Drupal\parallax_bg\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class ParallaxElementDeleteForm extends EntityConfirmFormBase {
public function getQuestion() {
$entity = $this->entity;
return $this
->t('Are you sure you want to delete %name?', [
'%name' => $entity
->getSelector(),
]);
}
public function getCancelUrl() {
return new Url('entity.parallax_element.collection');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->entity;
$entity
->delete();
drupal_set_message($this
->t('content @type: deleted @label.', [
'@type' => $entity
->bundle(),
'@label' => $entity
->getSelector(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}