function WorkflowEditForm::copyFormValuesToEntity

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

Overrides EntityForm::copyFormValuesToEntity

File

core/modules/workflows/src/Form/WorkflowEditForm.php, line 268

Class

WorkflowEditForm
The form for editing workflows.

Namespace

Drupal\workflows\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
    // This form can only set the workflow's ID, label and the weights for each
    // state.
    
    /** @var \Drupal\workflows\WorkflowInterface $entity */
    $values = $form_state->getValues();
    $entity->set('label', $values['label']);
    $entity->set('id', $values['id']);
    foreach ($values['states'] as $state_id => $state_values) {
        $entity->getTypePlugin()
            ->setStateWeight($state_id, $state_values['weight']);
    }
    foreach ($values['transitions'] as $transition_id => $transition_values) {
        $entity->getTypePlugin()
            ->setTransitionWeight($transition_id, $transition_values['weight']);
    }
}

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