function EntityTypeInfo::bundleFormRedirect
Same name in other branches
- 8.9.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::bundleFormRedirect()
- 10 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::bundleFormRedirect()
- 11.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::bundleFormRedirect()
Redirect content entity edit forms on save, if there is a pending 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 397
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderationCode
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->hasPendingRevision($entity) && $entity->hasLinkTemplate('latest-version')) {
$entity_type_id = $entity->getEntityTypeId();
$form_state->setRedirect("entity.{$entity_type_id}.latest_version", [
$entity_type_id => $entity->id(),
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.