You are here

function commerce_avatax_entity_field_access in Drupal Commerce Connector for AvaTax 8

Implements hook_entity_field_access().

File

./commerce_avatax.module, line 80
Provides module functionality.

Code

function commerce_avatax_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  if (in_array($field_definition
    ->getName(), [
    'avatax_customer_code',
    'avatax_tax_exemption_type',
    'avatax_tax_exemption_number',
  ], TRUE) && $operation == 'edit') {
    return AccessResult::forbiddenIf(!$account
      ->hasPermission('configure avatax exemptions'));
  }
  return AccessResult::neutral();
}