You are here

function rac_fca_field_collection_item_grants in Role Access Control 8

Implements hook_field_collection_item_grants().

File

contrib/rac_fca/rac_fca.module, line 15
Module providing role base access for field collection items.

Code

function rac_fca_field_collection_item_grants($op, AccountInterface $account) {
  $grants = [];
  if ($op === 'view' && ($g = rac_fca_field_collection_item_grants('update', $account))) {
    $grants = $g;
  }
  $access = $op === 'view' ? 1 : 2;
  $userRoles = _rac_get_account_roles($op, $account);
  foreach ($userRoles as $role) {
    $grants["rac_" . $role
      ->id()][] = $access;
  }
  if (count($grants)) {
    return $grants;
  }
}