You are here

public function ContentModerationConfigureEntityTypesForm::submitForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php \Drupal\content_moderation\Form\ContentModerationConfigureEntityTypesForm::submitForm()
  2. 10 core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php \Drupal\content_moderation\Form\ContentModerationConfigureEntityTypesForm::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/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php, line 181

Class

ContentModerationConfigureEntityTypesForm
The form for editing entity types associated with a workflow.

Namespace

Drupal\content_moderation\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($form_state
    ->getValue('bundles') as $bundle_id => $checked) {
    if ($checked) {
      $this->workflow
        ->getTypePlugin()
        ->addEntityTypeAndBundle($this->entityType
        ->id(), $bundle_id);
    }
    else {
      $this->workflow
        ->getTypePlugin()
        ->removeEntityTypeAndBundle($this->entityType
        ->id(), $bundle_id);
    }
  }
  $this->workflow
    ->save();
}