Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LatestRevisionCheck.php

function 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()));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal