public function AccessCheck::isAccessAllowedByDatabase in Permissions by Term 8.2
Same name and namespace in other branches
- 8 src/Service/AccessCheck.php \Drupal\permissions_by_term\Service\AccessCheck::isAccessAllowedByDatabase()
Parameters
int $tid:
bool|int $uid:
string $langcode:
Return value
bool
2 calls to AccessCheck::isAccessAllowedByDatabase()
- AccessCheck::canUserAccessByNode in src/
Service/ AccessCheck.php - AccessChecker::isAccessAllowed in modules/
permissions_by_entity/ src/ Service/ AccessChecker.php - Checks if a user is allowed to access a fieldable entity.
File
- src/
Service/ AccessCheck.php, line 123
Class
- AccessCheck
- AccessCheckService class.
Namespace
Drupal\permissions_by_term\ServiceCode
public function isAccessAllowedByDatabase($tid, $uid = FALSE, $langcode = '') {
$langcode = $langcode === '' ? \Drupal::languageManager()
->getCurrentLanguage()
->getId() : $langcode;
if (is_numeric($uid) && $uid > 0) {
$user = User::load($uid);
}
else {
$user = \Drupal::currentUser();
}
$tid = (int) $tid;
if (!$this
->isAnyPermissionSetForTerm($tid, $langcode) && !\Drupal::config('permissions_by_term.settings')
->get('permission_mode')) {
return TRUE;
}
/* At this point permissions are enabled, check to see if this user or one
* of their roles is allowed.
*/
foreach ($user
->getRoles() as $sUserRole) {
if ($this
->isTermAllowedByUserRole($tid, $sUserRole, $langcode)) {
return TRUE;
}
}
if ($this
->isTermAllowedByUserId($tid, $user
->id(), $langcode)) {
return TRUE;
}
return FALSE;
}