You are here

public function WorkflowStateDeleteForm::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::buildForm()
  2. 10 core/modules/workflows/src/Form/WorkflowStateDeleteForm.php \Drupal\workflows\Form\WorkflowStateDeleteForm::buildForm()

Form constructor.

Parameters

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

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

\Drupal\workflows\WorkflowInterface $workflow: The workflow entity being edited.

string|null $workflow_state: The workflow state being deleted.

Return value

array The form structure.

Overrides ConfirmFormBase::buildForm

File

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

Class

WorkflowStateDeleteForm
Builds the form to delete states from Workflow entities.

Namespace

Drupal\workflows\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, WorkflowInterface $workflow = NULL, $workflow_state = NULL) {
  if (!$workflow
    ->getTypePlugin()
    ->hasState($workflow_state)) {
    throw new NotFoundHttpException();
  }
  $this->workflow = $workflow;
  $this->stateId = $workflow_state;
  if ($this->workflow
    ->getTypePlugin()
    ->workflowStateHasData($this->workflow, $this->workflow
    ->getTypePlugin()
    ->getState($this->stateId))) {
    $form['#title'] = $this
      ->getQuestion();
    $form['description'] = [
      '#markup' => $this
        ->t('This workflow state is in use. You cannot remove this workflow state until you have removed all content using it.'),
    ];
    return $form;
  }
  return parent::buildForm($form, $form_state);
}