You are here

function profile_jsonapi_entity_field_filter_access in Profile 8

Implements hook_jsonapi_entity_field_filter_access().

File

./profile.module, line 94
Support for configurable user profiles.

Code

function profile_jsonapi_entity_field_filter_access(FieldDefinitionInterface $field_definition, AccountInterface $account) {
  if ($field_definition
    ->getTargetEntityTypeId() == 'profile') {
    if ($field_definition instanceof FieldConfigInterface) {
      $is_private = $field_definition
        ->getThirdPartySetting('profile', 'profile_private', FALSE);
      if ($is_private) {
        return AccessResult::forbiddenIf(!$account
          ->hasPermission('administer profile'));
      }
    }
  }
  return AccessResult::neutral();
}