You are here

protected function MongodbPathAliasStorage::mongodbAliasQuery in MongoDB 8

Parameters

$args:

$langcode:

Return value

array

4 calls to MongodbPathAliasStorage::mongodbAliasQuery()
MongodbPathAliasStorage::lookupPathAlias in src/MongodbPathAliasStorage.php
Returns an alias of Drupal system URL.
MongodbPathAliasStorage::lookupPathSource in src/MongodbPathAliasStorage.php
Returns Drupal system URL of an alias.
MongodbPathAliasStorage::pathHasMatchingAlias in src/MongodbPathAliasStorage.php
Check if any alias exists starting with $initial_substring.
MongodbPathAliasStorage::preloadPathAlias in src/MongodbPathAliasStorage.php
Pre-loads path alias information for a given list of source paths.

File

src/MongodbPathAliasStorage.php, line 161
Contains Drupal\mongodb\Path.

Class

MongodbPathAliasStorage
Provides a class for CRUD operations on path aliases in MongoDB.

Namespace

Drupal\mongodb

Code

protected function mongodbAliasQuery($args, $langcode = NULL, $limit = NULL) {
  if (isset($langcode)) {
    $args['langcode']['$in'] = [
      Language::LANGCODE_NOT_SPECIFIED,
    ];
    if ($langcode != Language::LANGCODE_NOT_SPECIFIED) {
      $args['langcode']['$in'][] = $langcode;
      $sort = [
        'langcode' => $langcode < Language::LANGCODE_NOT_SPECIFIED ? 1 : -1,
      ];
    }
  }
  $sort['_id'] = 1;
  $fields = [
    'source' => 1,
    'alias' => 1,
  ];
  $cursor = $this
    ->mongoCollection()
    ->find($args, $fields)
    ->sort($sort);
  if (isset($limit)) {
    $cursor
      ->limit($limit);
  }
  $result = [];
  foreach ($cursor as $item) {
    $result[$item['source']] = $item['alias'];
  }
  return $result;
}