You are here

function private_content_entity_field_access in Private content 8.2

Implements hook_entity_field_access().

File

./private_content.module, line 146
A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.

Code

function private_content_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemList $items = NULL) {

  // Block edit access if private field is locked.
  if ($field_definition
    ->getName() == 'private' && $operation == 'edit' && $items
    ->isLocked()) {
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
}