function jsonapi_jsonapi_comment_filter_access

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/jsonapi.module \jsonapi_jsonapi_comment_filter_access()
  2. 8.9.x core/modules/jsonapi/jsonapi.module \jsonapi_jsonapi_comment_filter_access()
  3. 10 core/modules/jsonapi/jsonapi.module \jsonapi_jsonapi_comment_filter_access()

Implements hook_jsonapi_ENTITY_TYPE_filter_access() for 'comment'.

File

core/modules/jsonapi/jsonapi.module, line 194

Code

function jsonapi_jsonapi_comment_filter_access(EntityTypeInterface $entity_type, AccountInterface $account) {
    // @see \Drupal\comment\CommentAccessControlHandler::checkAccess()
    // \Drupal\jsonapi\Access\TemporaryQueryGuard adds the condition for
    // (access to the commented entity), so this does not have to.
    return [
        JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, 'administer comments'),
        JSONAPI_FILTER_AMONG_PUBLISHED => AccessResult::allowedIfHasPermission($account, 'access comments'),
    ];
}

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