You are here

public function AccessStorage::getPermittedTids 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::getPermittedTids()

Parameters

int $uid:

array $rids:

Return value

array

1 call to AccessStorage::getPermittedTids()
AccessStorage::computePermittedTids in src/Service/AccessStorage.php

File

src/Service/AccessStorage.php, line 140

Class

AccessStorage
Class AccessStorage.

Namespace

Drupal\permissions_by_term\Service

Code

public function getPermittedTids($uid, $rids) {
  $permittedTids = $this->database
    ->select('permissions_by_term_user', 'pu')
    ->condition('uid', $uid)
    ->fields('pu', [
    'tid',
  ])
    ->execute()
    ->fetchCol();
  foreach ($rids as $rid) {
    $permittedTidsByRid = $this->database
      ->select('permissions_by_term_role', 'pr')
      ->condition('rid', $rid)
      ->fields('pr', [
      'tid',
    ])
      ->execute()
      ->fetchCol();
    $permittedTids = array_merge($permittedTidsByRid, $permittedTids);
  }
  return array_unique($permittedTids);
}