You are here

public function WorkflowConfigTransitionRoleForm::submitForm in Workflow 8

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 ConfigFormBase::submitForm

File

src/Form/WorkflowConfigTransitionRoleForm.php, line 163

Class

WorkflowConfigTransitionRoleForm
Defines a class to build a listing of Workflow Config Transitions entities.

Namespace

Drupal\workflow\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($form_state
    ->getValue($this->entitiesKey) as $from_sid => $to_data) {
    foreach ($to_data as $transition_data) {

      /** @var \Drupal\workflow\Entity\WorkflowConfigTransition $config_transition */
      if (isset($transition_data['workflow_config_transition'])) {
        $config_transition = $transition_data['workflow_config_transition'];
        $config_transition->roles = $transition_data['roles'];
        $config_transition
          ->save();
      }
      else {

        // Should not be possible.
      }
    }
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('The workflow was updated.'));
}