You are here

public function WorkflowStateDeleteForm::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

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());
}