public EntityModerationForm::submitForm(array &$form, FormStateInterface $form_state)
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/EntityModerationForm.php, line 134
 
Class
- EntityModerationForm
 - The EntityModerationForm provides a simple UI for changing moderation state.
 
Namespace
Drupal\content_moderation\Form
Code
public function submitForm(array &$form, FormStateInterface $form_state) {
  /** @var ContentEntityInterface $entity */
  $entity = $form_state->get('entity');
  $new_state = $form_state->getValue('new_state');
  // @todo should we just just be updating the content moderation state
  //   entity? That would prevent setting the revision log.
  $entity->moderation_state->target_id = $new_state;
  $entity->revision_log = $form_state->getValue('revision_log');
  $entity->save();
  drupal_set_message($this->t('The moderation state has been updated.'));
  /** @var \Drupal\content_moderation\Entity\ModerationState $state */
  $state = $this->entityTypeManager->getStorage('moderation_state')->load($new_state);
  // The page we're on likely won't be visible if we just set the entity to
  // the default state, as we hide that latest-revision tab if there is no
  // forward revision. Redirect to the canonical URL instead, since that will
  // still exist.
  if ($state->isDefaultRevisionState()) {
    $form_state->setRedirectUrl($entity->toUrl('canonical'));
  }
}
Please login to continue.