You are here

public function UserRevisionAccessCheck::access in User Revision 8

Checks routing access for the user revision.

Parameters

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

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

int $user_revision: (optional) The user revision ID. If not specified, but $node is, access is checked for that object's revision.

\Drupal\user\UserInterface $user: (optional) A user object. Used for checking access to a user's default revision when $user_revision is unspecified. Ignored when $user_revision is specified. If neither $user_revision nor $user are specified, then access is denied.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

src/Access/UserRevisionAccessCheck.php, line 69

Class

UserRevisionAccessCheck
Provides an access checker for user revisions.

Namespace

Drupal\user_revision\Access

Code

public function access(Route $route, AccountInterface $account, $user_revision = NULL, UserInterface $user = NULL) {
  if ($user_revision) {
    $user = $this->userStorage
      ->loadRevision($user_revision);
  }
  $operation = $route
    ->getRequirement('_access_user_revision');
  return AccessResult::allowedIf($user && $this
    ->checkAccess($user, $account, $operation));
}