function WorkflowStateDeleteForm::submitForm

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::submitForm()
  2. 10 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::submitForm()
  3. 11.x core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/workflows/src/Form/WorkflowStateDeleteForm.php, line 93

Class

WorkflowStateDeleteForm
Builds the form to delete states from Workflow entities.

Namespace

Drupal\workflows\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $workflow_label = $this->workflow
        ->getTypePlugin()
        ->getState($this->stateId)
        ->label();
    $this->workflow
        ->getTypePlugin()
        ->deleteState($this->stateId);
    $this->workflow
        ->save();
    $this->messenger()
        ->addStatus($this->t('State %label deleted.', [
        '%label' => $workflow_label,
    ]));
    $form_state->setRedirectUrl($this->getCancelUrl());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.