public static function EntityTypeInfo::bundleFormRedirect in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/EntityTypeInfo.php \Drupal\workbench_moderation\EntityTypeInfo::bundleFormRedirect()
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: Form array.
\Drupal\Core\Form\FormStateInterface $form_state: Form state.
File
- src/
EntityTypeInfo.php, line 353
Class
- EntityTypeInfo
- Service class for manipulating entity type information.
Namespace
Drupal\workbench_moderationCode
public static function bundleFormRedirect(array &$form, FormStateInterface $form_state) {
/* @var ContentEntityInterface $entity */
$entity = $form_state
->getFormObject()
->getEntity();
$moderation_info = \Drupal::getContainer()
->get('workbench_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(),
]);
}
}