public function AccessStorage::getGids in Permissions by Term 8.2
Same name and namespace in other branches
- 8 src/Service/AccessStorage.php \Drupal\permissions_by_term\Service\AccessStorage::getGids()
Parameters
AccountInterface $user:
Return value
array
File
- src/
Service/ AccessStorage.php, line 632
Class
- AccessStorage
- Class AccessStorage.
Namespace
Drupal\permissions_by_term\ServiceCode
public function getGids(AccountInterface $user) {
$grants = null;
if (!empty($this->grantsCache[$user
->id()])) {
return $this->grantsCache[$user
->id()];
}
if (!empty($permittedNids = $this
->computePermittedTids($user))) {
$query = $this->database
->select('node_access', 'na')
->fields('na', [
'gid',
])
->condition('na.nid', $permittedNids, 'IN')
->condition('na.realm', self::NODE_ACCESS_REALM);
$gids = $query
->execute()
->fetchCol();
foreach ($gids as $gid) {
$grants[self::NODE_ACCESS_REALM][] = $gid;
}
}
$this->grantsCache[$user
->id()] = $grants;
return $grants;
}