You are here

public function NodeGrantDatabaseStorage::checkAll in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/src/NodeGrantDatabaseStorage.php \Drupal\node\NodeGrantDatabaseStorage::checkAll()
  2. 10 core/modules/node/src/NodeGrantDatabaseStorage.php \Drupal\node\NodeGrantDatabaseStorage::checkAll()

Checks all grants for a given account.

Parameters

\Drupal\Core\Session\AccountInterface $account: A user object representing the user for whom the operation is to be performed.

Return value

int Status of the access check.

Overrides NodeGrantDatabaseStorageInterface::checkAll

File

core/modules/node/src/NodeGrantDatabaseStorage.php, line 132

Class

NodeGrantDatabaseStorage
Defines a storage handler class that handles the node grants system.

Namespace

Drupal\node

Code

public function checkAll(AccountInterface $account) {
  $query = $this->database
    ->select('node_access');
  $query
    ->addExpression('COUNT(*)');
  $query
    ->condition('nid', 0)
    ->condition('grant_view', 1, '>=');
  $grants = static::buildGrantsQueryCondition(node_access_grants('view', $account));
  if (count($grants) > 0) {
    $query
      ->condition($grants);
  }
  return $query
    ->execute()
    ->fetchField();
}