You are here

protected function LatestRevisionCheck::loadEntity in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/Access/LatestRevisionCheck.php \Drupal\workbench_moderation\Access\LatestRevisionCheck::loadEntity()

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

\Exception A generic exception is thrown if the entity couldn't be loaded. This almost always implies a developer error, so it should get turned into an HTTP 500.

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

File

src/Access/LatestRevisionCheck.php, line 76

Class

LatestRevisionCheck
Define class for revision checks.

Namespace

Drupal\workbench_moderation\Access

Code

protected function loadEntity(Route $route, RouteMatchInterface $route_match) {
  $entity_type = $route
    ->getOption('_workbench_moderation_entity_type');
  if ($entity = $route_match
    ->getParameter($entity_type)) {
    if ($entity instanceof EntityInterface) {
      return $entity;
    }
  }
  throw new \Exception(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()));
}