You are here

function eck_jsonapi_entity_filter_access in Entity Construction Kit (ECK) 8

Implements hook_jsonapi_entity_filter_access() for all eck entities.

File

./eck.module, line 330
Contains hook implementations.

Code

function eck_jsonapi_entity_filter_access(ContentEntityType $entity_type, AccountInterface $account) {
  $result = [];
  if ($entity_type
    ->getProvider() == 'eck') {
    $result = [
      JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, "view any {$entity_type->id()} entities"),
      JSONAPI_FILTER_AMONG_OWN => AccessResult::allowedIfHasPermission($account, "view own {$entity_type->id()} entities"),
    ];
  }
  return $result;
}