function 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 122
Class
- NodeGrantDatabaseStorage
- Defines a storage handler class that handles the node grants system.
Namespace
Drupal\nodeCode
public function checkAll(AccountInterface $account) {
// If no modules implement the node access system, access is always 1.
if (!$this->hasNodeGrantsImplementations) {
return 1;
}
$cacheItem = $this->memoryCache
->get($account->id());
if ($cacheItem) {
return $cacheItem->data;
}
$query = $this->database
->select('node_access');
$query->addExpression('COUNT(*)');
$query->condition('nid', 0)
->condition('grant_view', 1, '>=');
$grants = $this->buildGrantsQueryCondition(node_access_grants('view', $account));
if (count($grants) > 0) {
$query->condition($grants);
}
$access = $query->execute()
->fetchField();
$this->memoryCache
->set($account->id(), $access);
return $access;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.