You are here

protected function MongodbNodeGrantStorage::buildGrantsQueryCondition in MongoDB 8

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 MongodbNodeGrantStorage::buildGrantsQueryCondition()
MongodbNodeGrantStorage::access in mongodb_node/src/MongodbNodeGrantStorage.php
Determines access to nodes based on node grants.
MongodbNodeGrantStorage::alterQuery in mongodb_node/src/MongodbNodeGrantStorage.php
Alters a query when node access is required.
MongodbNodeGrantStorage::checkAll in mongodb_node/src/MongodbNodeGrantStorage.php
Checks all grants for a given account.

File

mongodb_node/src/MongodbNodeGrantStorage.php, line 282
Contains \Drupal\node\NodeGrantDatabaseStorage.

Class

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

Namespace

Drupal\mongodb_node

Code

protected function buildGrantsQueryCondition(array $node_access_grants, $langcodes, $fallbacks = [
  0,
  1,
]) {
  $conditions = [];
  if (!is_array($langcodes)) {
    $langcodes = [
      $langcodes,
    ];
  }
  foreach ($node_access_grants as $realm => $gids) {
    if (!empty($gids)) {
      foreach ($gids as $gid) {
        foreach ($langcodes as $langcode) {
          foreach ($fallbacks as $fallback) {
            $conditions[] = [
              'langcode' => $langcode,
              'fallback' => $fallback,
              'gid' => $gid,
              'realm' => $realm,
            ];
          }
        }
      }
    }
  }
  return $conditions;
}