You are here

function commerce_purchase_order_entity_field_access in Commerce Purchase Order 8

Implements hook_entity_field_access().

File

./commerce_purchase_order.module, line 36
Contains commerce_purchase_order.module..

Code

function commerce_purchase_order_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  if ($field_definition
    ->getName() == 'field_purchase_orders_authorized') {
    if ($account
      ->hasPermission('authorize user purchase orders')) {
      return AccessResult::allowed();
    }
    else {
      return AccessResult::forbidden();
    }
  }
  else {
    return AccessResult::neutral();
  }
}