function jsonapi_jsonapi_entity_filter_access

Implements hook_jsonapi_entity_filter_access().

File

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

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),
    ];
  }
}

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