You are here

public function AccessCheck::isAnyPermissionSetForTerm in Permissions by Term 8

Same name and namespace in other branches
  1. 8.2 src/Service/AccessCheck.php \Drupal\permissions_by_term\Service\AccessCheck::isAnyPermissionSetForTerm()

Parameters

int $tid:

string $langcode:

Return value

bool

1 call to AccessCheck::isAnyPermissionSetForTerm()
AccessCheck::isAccessAllowedByDatabase in src/Service/AccessCheck.php

File

src/Service/AccessCheck.php, line 178

Class

AccessCheck
AccessCheckService class.

Namespace

Drupal\permissions_by_term\Service

Code

public function isAnyPermissionSetForTerm($tid, $langcode = '') {
  $langcode = $langcode === '' ? \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId() : $langcode;
  $iUserTableResults = intval($this->database
    ->query("SELECT COUNT(1) FROM {permissions_by_term_user} WHERE tid = :tid AND langcode = :langcode", [
    ':tid' => $tid,
    ':langcode' => $langcode,
  ])
    ->fetchField());
  $iRoleTableResults = intval($this->database
    ->query("SELECT COUNT(1) FROM {permissions_by_term_role} WHERE tid = :tid AND langcode = :langcode", [
    ':tid' => $tid,
    ':langcode' => $langcode,
  ])
    ->fetchField());
  if ($iUserTableResults > 0 || $iRoleTableResults > 0) {
    return TRUE;
  }
}