You are here

private function AccessStorage::computePermittedTids in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 src/Service/AccessStorage.php \Drupal\permissions_by_term\Service\AccessStorage::computePermittedTids()
1 call to AccessStorage::computePermittedTids()
AccessStorage::getGids in src/Service/AccessStorage.php

File

src/Service/AccessStorage.php, line 658

Class

AccessStorage
Class AccessStorage.

Namespace

Drupal\permissions_by_term\Service

Code

private function computePermittedTids(AccountInterface $user) {
  $nidsWithNoTidRestriction = $this
    ->getUnrestrictedNids();
  $nidsByTids = $this->term
    ->getNidsByTidsForPublishedNodes($this
    ->getPermittedTids($user
    ->id(), $user
    ->getRoles()));
  if (\Drupal::config('permissions_by_term.settings')
    ->get('require_all_terms_granted')) {
    $permittedNids = [];
    foreach ($nidsByTids as $nid) {
      if ($this->accessCheck
        ->canUserAccessByNode(Node::load($nid), $user
        ->id(), $this
        ->getLangCode($nid))) {
        $permittedNids[] = $nid;
      }
    }
    $nidsByTids = $permittedNids;
  }
  if (!empty($nidsByTids)) {
    return array_merge($this
      ->getUnrestrictedNids(), $nidsByTids);
  }
  return $nidsWithNoTidRestriction;
}