public function AccessStorage::addTermPermissionsByUserIds in Permissions by Term 8.2
Same name and namespace in other branches
- 8 src/Service/AccessStorage.php \Drupal\permissions_by_term\Service\AccessStorage::addTermPermissionsByUserIds()
1 call to AccessStorage::addTermPermissionsByUserIds()
- AccessStorage::saveTermPermissions in src/
Service/ AccessStorage.php
File
- src/
Service/ AccessStorage.php, line 310
Class
- AccessStorage
- Class AccessStorage.
Namespace
Drupal\permissions_by_term\ServiceCode
public function addTermPermissionsByUserIds(array $aUserIdsGrantedAccess, int $term_id, string $langcode = '') : void {
$langcode = $langcode === '' ? \Drupal::languageManager()
->getCurrentLanguage()
->getId() : $langcode;
foreach ($aUserIdsGrantedAccess as $iUserIdGrantedAccess) {
$queryResult = $this->database
->query("SELECT uid FROM {permissions_by_term_user} WHERE tid = :tid AND uid = :uid AND langcode = :langcode", [
':tid' => $term_id,
':uid' => $iUserIdGrantedAccess,
':langcode' => $langcode,
])
->fetchField();
if (empty($queryResult)) {
$this->database
->insert('permissions_by_term_user')
->fields([
'tid',
'uid',
'langcode',
], [
$term_id,
$iUserIdGrantedAccess,
$langcode,
])
->execute();
}
}
}