$access_result = AccessResult::
allowedIfHasPermissions($account,
['view latest version', 'view any unpublished content'
]);
if (!
$access_result->
isAllowed()) { // Check entity owner access.
$owner_access = AccessResult::
allowedIfHasPermissions($account,
['view latest version', 'view own unpublished content'
]);
$owner_access =
$owner_access->
andIf((AccessResult::
allowedIf($entity instanceof EntityOwnerInterface
&& ($entity->
getOwnerId() ==
$account->
id()))));
$access_result =
$access_result->
orIf($owner_access);
} return $access_result->
addCacheableDependency($entity);
} return AccessResult::
forbidden('No pending revision for moderated entity.'
)->
addCacheableDependency($entity);
} /**
* Returns the default revision of the entity this route is for.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The parametrized route.
*
* @return \Drupal\Core\Entity\ContentEntityInterface
* returns the Entity in question.
*
* @throws \Drupal\Core\Access\AccessException
* An AccessException is thrown if the entity couldn't be loaded.
*/