/**
* Gets the moderation-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getLatestVersionRoute(EntityTypeInterface
$entity_type) { if ($entity_type->
hasLinkTemplate('latest-version'
) &&
$entity_type->
hasViewBuilderClass()) { $entity_type_id =
$entity_type->
id();
$route =
new Route($entity_type->
getLinkTemplate('latest-version'
));
$route ->
addDefaults([ '_entity_view' => "{
$entity_type_id}.full",
'_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::title',
]) // If the entity type is a node, unpublished content will be visible
// if the user has the "view any unpublished content" permission.
->
setRequirement('_entity_access', "{
$entity_type_id}.view"
) ->
setRequirement('_content_moderation_latest_version', 'TRUE'
)