/**
  * Checks that there is a forward revision available.
  *
  * This checker assumes the presence of an '_entity_access' requirement key
  * in the same form as used by EntityAccessCheck.
  *
  * @see EntityAccessCheck.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The parametrized route
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, RouteMatchInterface $route_match)
 {
     // This tab should not show up period unless there's a reason to show it.
     // @todo Do we need any extra cache tags here?
     $entity = $this->loadEntity($route, $route_match);
     return $this->moderationInfo->hasForwardRevision($entity) ? AccessResult::allowed()->addCacheableDependency($entity) : AccessResult::forbidden()->addCacheableDependency($entity);
 }
 /**
  * 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.
  *
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  */
 public function bundleFormRedirect(array &$form, FormStateInterface $form_state)
 {
     /* @var ContentEntityInterface $entity */
     $entity = $form_state->getFormObject()->getEntity();
     if ($this->moderationInfo->hasForwardRevision($entity)) {
         $entity_type_id = $entity->getEntityTypeId();
         $form_state->setRedirect("entity.{$entity_type_id}.latest_version", [$entity_type_id => $entity->id()]);
     }
 }