BundleModerationConfigurationForm::formBuilderCallback

public BundleModerationConfigurationForm::formBuilderCallback($entity_type_id, EntityInterface $bundle, &$form, FormStateInterface $form_state)

Form builder callback.

@todo This should be folded into the form method.

Parameters

string $entity_type_id: The entity type identifier.

\Drupal\Core\Entity\EntityInterface $bundle: The bundle entity updated with the submitted values.

array $form: The complete form array.

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

File

core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php, line 155

Class

BundleModerationConfigurationForm
Form for configuring moderation usage on a given entity bundle.

Namespace

Drupal\content_moderation\Form

Code

public function formBuilderCallback($entity_type_id, EntityInterface $bundle, &$form, FormStateInterface $form_state) {
  // @todo https://www.drupal.org/node/2779933 write a test for this.
  if ($bundle instanceof ThirdPartySettingsInterface) {
    $bundle->setThirdPartySetting('content_moderation', 'enabled', $form_state->getValue('enable_moderation_state'));
    $bundle->setThirdPartySetting('content_moderation', 'allowed_moderation_states', array_keys(array_filter($form_state->getValue('allowed_moderation_states_published') + $form_state->getValue('allowed_moderation_states_unpublished'))));
    $bundle->setThirdPartySetting('content_moderation', 'default_moderation_state', $form_state->getValue('default_moderation_state'));
  }
}
doc_Drupal
2016-10-29 08:49:05
Comments
Leave a Comment

Please login to continue.