function jsonapi_jsonapi_entity_filter_access in JSON:API 8.2
Same name and namespace in other branches
- 8 jsonapi.module \jsonapi_jsonapi_entity_filter_access()
Implements hook_jsonapi_entity_filter_access().
File
- ./
jsonapi.module, line 181 - 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),
];
}
}