You are here

protected static function NodeGrantDatabaseStorage::buildGrantsQueryCondition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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()

3 calls to NodeGrantDatabaseStorage::buildGrantsQueryCondition()
NodeGrantDatabaseStorage::access in core/modules/node/src/NodeGrantDatabaseStorage.php
Determines access to nodes based on node grants.
NodeGrantDatabaseStorage::alterQuery in core/modules/node/src/NodeGrantDatabaseStorage.php
Alters a query when node access is required.
NodeGrantDatabaseStorage::checkAll in core/modules/node/src/NodeGrantDatabaseStorage.php
Checks all grants for a given account.

File

core/modules/node/src/NodeGrantDatabaseStorage.php, line 293
Contains \Drupal\node\NodeGrantDatabaseStorage.

Class

NodeGrantDatabaseStorage
Defines a controller class that handles the node grants system.

Namespace

Drupal\node

Code

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