EntityTypeInfo::bundleFormRedirect

public static EntityTypeInfo::bundleFormRedirect(array &$form, FormStateInterface $form_state)

Redirect content entity edit forms on save, if there is a forward revision.

When saving their changes, editors should see those changes displayed on the next page.

Parameters

array $form: An associative array containing the structure of the form.

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

File

core/modules/content_moderation/src/EntityTypeInfo.php, line 379

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\content_moderation

Code

public static function bundleFormRedirect(array &$form, FormStateInterface $form_state) {
  /* @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $form_state->getFormObject()->getEntity();

  $moderation_info = \Drupal::getContainer()->get('content_moderation.moderation_information');
  if ($moderation_info->hasForwardRevision($entity) && $entity->hasLinkTemplate('latest-version')) {
    $entity_type_id = $entity->getEntityTypeId();
    $form_state->setRedirect("entity.$entity_type_id.latest_version", [$entity_type_id => $entity->id()]);
  }
}
doc_Drupal
2016-10-29 09:08:16
Comments
Leave a Comment

Please login to continue.