protected function checkRevisionViewAccess(EntityInterface
$entity, AccountInterface
$account) { assert($entity instanceof RevisionableInterface
);
assert(!
$entity->
isDefaultRevision(), 'It is not necessary to check revision access when the entity is the default revision.'
);
$entity_type =
$entity->
getEntityType();
$access =
$entity->
access('view all revisions',
$account, TRUE
);
// Apply content_moderation's additional access logic.
// @see \Drupal\content_moderation\Access\LatestRevisionCheck::access()
if ($entity_type->
getLinkTemplate('latest-version'
) &&
$entity->
isLatestRevision() &&
isset($this->latestRevisionCheck
)) { // The latest revision access checker only expects to be invoked by the
// routing system, which makes it necessary to fake a route match.
$routes =
$this->router->
getRouteCollection();
$resource_type =
$this->resourceTypeRepository->
get($entity->
getEntityTypeId(),
$entity->
bundle());
$route_name =
sprintf('jsonapi.%s.individual',
$resource_type->
getTypeName());
$route =
$routes->
get($route_name);
$route->
setOption('_content_moderation_entity_type', 'entity'
);
$route_match =
new RouteMatch($route_name,
$route,
['entity' =>
$entity],
['entity' =>
$entity->
uuid()]);
$moderation_access_result =
$this->latestRevisionCheck->
access($route,
$route_match,
$account);
$access =
$access->
andIf($moderation_access_result);
} return $access;
}}