function LatestRevisionCheck::loadEntity

Same name in other branches
  1. 8.9.x core/modules/content_moderation/src/Access/LatestRevisionCheck.php \Drupal\content_moderation\Access\LatestRevisionCheck::loadEntity()
  2. 10 core/modules/content_moderation/src/Access/LatestRevisionCheck.php \Drupal\content_moderation\Access\LatestRevisionCheck::loadEntity()
  3. 11.x core/modules/content_moderation/src/Access/LatestRevisionCheck.php \Drupal\content_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

\Drupal\Core\Access\AccessException An AccessException is thrown if the entity couldn't be loaded.

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

File

core/modules/content_moderation/src/Access/LatestRevisionCheck.php, line 88

Class

LatestRevisionCheck
Access check for the entity moderation tab.

Namespace

Drupal\content_moderation\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()));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.