3 namespace Drupal\workflows\Form;
5 use Drupal\Core\Entity\EntityConfirmFormBase;
6 use Drupal\Core\Form\FormStateInterface;
10 * Builds the form to delete Workflow entities.
14 class WorkflowDeleteForm extends EntityConfirmFormBase {
19 public function buildForm(array $form, FormStateInterface $form_state) {
20 if ($this->entity->getTypePlugin()->workflowHasData($this->entity)) {
21 $form['#title'] = $this->getQuestion();
22 $form['description'] = ['#markup' => $this->t('This workflow is in use. You cannot remove this workflow until you have removed all content using it.')];
26 return parent::buildForm($form, $form_state);
32 public function getQuestion() {
33 return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
39 public function getCancelUrl() {
40 return new Url('entity.workflow.collection');
46 public function getConfirmText() {
47 return $this->t('Delete');
53 public function submitForm(array &$form, FormStateInterface $form_state) {
54 $this->entity->delete();
56 drupal_set_message($this->t(
57 'Workflow %label deleted.',
58 ['%label' => $this->entity->label()]
61 $form_state->setRedirectUrl($this->getCancelUrl());