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.
12 class WorkflowDeleteForm extends EntityConfirmFormBase {
17 public function buildForm(array $form, FormStateInterface $form_state) {
18 if ($this->entity->getTypePlugin()->workflowHasData($this->entity)) {
19 $form['#title'] = $this->getQuestion();
20 $form['description'] = ['#markup' => $this->t('This workflow is in use. You cannot remove this workflow until you have removed all content using it.')];
24 return parent::buildForm($form, $form_state);
30 public function getQuestion() {
31 return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
37 public function getCancelUrl() {
38 return new Url('entity.workflow.collection');
44 public function getConfirmText() {
45 return $this->t('Delete');
51 public function submitForm(array &$form, FormStateInterface $form_state) {
52 $this->entity->delete();
54 drupal_set_message($this->t(
55 'Workflow %label deleted.',
56 ['%label' => $this->entity->label()]
59 $form_state->setRedirectUrl($this->getCancelUrl());