You are here

function jsonapi_jsonapi_entity_filter_access in Drupal 8

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

Implements hook_jsonapi_entity_filter_access().

File

core/modules/jsonapi/jsonapi.module, line 165
Module implementation file.

Code

function jsonapi_jsonapi_entity_filter_access(EntityTypeInterface $entity_type, AccountInterface $account) {

  // All core entity types and most or all contrib entity types allow users
  // with the entity type's administrative permission to view all of the
  // entities, so enable similarly permissive filtering to those users as well.
  // A contrib module may override this decision by returning
  // AccessResult::forbidden() from its implementation of this hook.
  if ($admin_permission = $entity_type
    ->getAdminPermission()) {
    return [
      JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, $admin_permission),
    ];
  }
}