You are here

protected function LatestRevisionCheck::loadEntity in Access unpublished 8

Returns the default revision of the entity this route is for.

Parameters

\Symfony\Component\Routing\Route $route: The route to check against.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The parametrized route.

Return value

\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.

Overrides LatestRevisionCheck::loadEntity

1 call to LatestRevisionCheck::loadEntity()
LatestRevisionCheck::access in src/Access/LatestRevisionCheck.php
Checks that there is a pending revision available.

File

src/Access/LatestRevisionCheck.php, line 74

Class

LatestRevisionCheck
Access check for the entity moderation tab which supports access_unpublished.

Namespace

Drupal\access_unpublished\Access

Code

protected function loadEntity(Route $route, RouteMatchInterface $route_match) {
  $entity_type = $route
    ->getOption('_content_moderation_entity_type');
  if ($entity = $route_match
    ->getParameter($entity_type)) {
    if ($entity instanceof EntityInterface) {
      return $entity;
    }
  }
  throw new AccessException(sprintf('%s is not a valid entity route. The LatestRevisionCheck access checker may only be used with a route that has a single entity parameter.', $route_match
    ->getRouteName()));
}