You are here

function permissions_by_term_node_grants in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 permissions_by_term.module \permissions_by_term_node_grants()

Implements hook_node_grants().

File

./permissions_by_term.module, line 378
Allows access to terms in a vocabulary to be limited by user or role.

Code

function permissions_by_term_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) {
  $grants = [];
  if ($op == 'view' && !\Drupal::configFactory()
    ->getEditable('permissions_by_term.settings')
    ->get('disable_node_access_records')) {

    /**
     * @var \Drupal\permissions_by_term\Service\AccessStorage $accessStorage
     */
    $accessStorage = \Drupal::service('permissions_by_term.access_storage');
    $grants = $accessStorage
      ->getGids($account);
  }
  return $grants;
}