You are here

protected function NodeGrantDatabaseStorage::buildGrantsQueryCondition in Drupal 10

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

Creates a query condition from an array of node access grants.

Parameters

array $node_access_grants: An array of grants, as returned by node_access_grants().

Return value

\Drupal\Core\Database\Query\Condition A condition object to be passed to $query->condition().

See also

node_access_grants()

File

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

Class

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

Namespace

Drupal\node

Code

protected function buildGrantsQueryCondition(array $node_access_grants) {
  $grants = $this->database
    ->condition('OR');
  foreach ($node_access_grants as $realm => $gids) {
    if (!empty($gids)) {
      $and = $this->database
        ->condition('AND');
      $grants
        ->condition($and
        ->condition('gid', $gids, 'IN')
        ->condition('realm', $realm));
    }
  }
  return $grants;
}