You are here

public function MongodbPathAliasStorage::aliasExists in MongoDB 8

Checks if alias already exists.

The default implementation performs case-insensitive matching on the 'source' and 'alias' strings.

Parameters

string $alias: Alias to check against.

string $langcode: Language of the alias.

string|null $source: (optional) Path that alias is to be assigned to.

Return value

bool TRUE if alias already exists and FALSE otherwise.

Overrides AliasStorageInterface::aliasExists

File

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

Class

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

Namespace

Drupal\mongodb

Code

public function aliasExists($alias, $langcode, $source = NULL) {
  $criteria = array(
    'alias' => $alias,
    'langcode' => $langcode,
  );
  if (!empty($source)) {
    $criteria['source'] = array(
      '$ne' => $source,
    );
  }
  return (bool) $this
    ->mongoCollection()
    ->count($criteria);
}