You are here

public function EntityRevisionRouteAccessChecker::access in Entity API 8

Same name and namespace in other branches
  1. 8.0 src/Access/EntityRevisionRouteAccessChecker.php \Drupal\entity\Access\EntityRevisionRouteAccessChecker::access()

File

src/Access/EntityRevisionRouteAccessChecker.php, line 54

Class

EntityRevisionRouteAccessChecker
Checks access to a entity revision.

Namespace

Drupal\entity\Access

Code

public function access(Route $route, AccountInterface $account, RouteMatchInterface $route_match = NULL) {
  if (empty($route_match)) {
    $route_match = $this->routeMatch;
  }
  $operation = $route
    ->getRequirement('_entity_access_revision');
  list($entity_type_id, $operation) = explode('.', $operation, 2);
  if ($operation === 'list') {
    $_entity = $route_match
      ->getParameter($entity_type_id);
    return AccessResult::allowedIf($this
      ->checkAccess($_entity, $account, $operation))
      ->cachePerPermissions();
  }
  else {
    $_entity_revision = $route_match
      ->getParameter($entity_type_id . '_revision');
    return AccessResult::allowedIf($_entity_revision && $this
      ->checkAccess($_entity_revision, $account, $operation))
      ->cachePerPermissions();
  }
}