You are here

private function AccessStorage::getUnrestrictedNids 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::getUnrestrictedNids()
1 call to AccessStorage::getUnrestrictedNids()
AccessStorage::computePermittedTids in src/Service/AccessStorage.php

File

src/Service/AccessStorage.php, line 683

Class

AccessStorage
Class AccessStorage.

Namespace

Drupal\permissions_by_term\Service

Code

private function getUnrestrictedNids() {
  $tidsRestrictedUserQuery = $this->database
    ->select('permissions_by_term_user', 'u')
    ->fields('u', [
    'tid',
  ]);
  $restrictedTids = $this->database
    ->select('permissions_by_term_role', 'r')
    ->fields('r', [
    'tid',
  ])
    ->union($tidsRestrictedUserQuery)
    ->execute()
    ->fetchCol();
  if (empty($restrictedTids)) {
    return $this
      ->getAllNids();
  }
  $restrictedNids = $this->database
    ->select('taxonomy_index', 't')
    ->fields('t', [
    'nid',
  ])
    ->condition('t.tid', $restrictedTids, 'IN')
    ->distinct(TRUE)
    ->execute()
    ->fetchCol();
  if (empty($restrictedNids)) {
    return $this
      ->getAllNids();
  }
  $unrestrictedNids = $this->database
    ->select('taxonomy_index', 't')
    ->fields('t', [
    'nid',
  ])
    ->condition('t.nid', $restrictedNids, 'NOT IN')
    ->distinct(TRUE)
    ->execute()
    ->fetchCol();
  return $unrestrictedNids;
}