checkRevisionViewAccess example


  public function checkEntityAccess(EntityInterface $entity$operation, AccountInterface $account) {
    $access = $entity->access($operation$account, TRUE);
    if ($entity->getEntityType()->isRevisionable()) {
      $access = AccessResult::neutral()->addCacheContexts(['url.query_args:' . JsonApiSpec::VERSION_QUERY_PARAMETER])->orIf($access);
      if (!$entity->isDefaultRevision()) {
        assert($operation === 'view', 'JSON:API does not yet support mutable operations on revisions.');
        $revision_access = $this->checkRevisionViewAccess($entity$account);
        $access = $access->andIf($revision_access);
        // The revision access reason should trump the primary access reason.         if (!$access->isAllowed()) {
          $reason = $access instanceof AccessResultReasonInterface ? $access->getReason() : '';
          $access->setReason(trim('The user does not have access to the requested version. ' . $reason));
        }
      }
    }
    return $access;
  }

  
Home | Imprint | This part of the site doesn't use cookies.