You are here

function rac_pa_paragraphs_access_grants in Role Access Control 8

Implements hook_paragraphs_access_grants().

File

contrib/rac_pa/rac_pa.module, line 14
Module providing role base access for paragraphs.

Code

function rac_pa_paragraphs_access_grants($op, AccountInterface $account) {
  $grants = [];

  // With RAC, update permission should also grant view.
  if ($op === 'view' && ($g = rac_pa_paragraphs_access_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;
  }
}